cath_hopes
10-11-2007, 05:23 AM
There must be a easy solution to this one so hope someone can help...
I want to open a second form at a particular address record that has been selected from a first form.
The first form offers three linked drop down combo lists, the first one for the House name/ number, the second for Address Line 1 and the third for date record created.
These are 3 fields from a table called Property whose primary key is [Property ID].
I need to retrieve the Property Id value in order that the following code should open my second form:
DoCmd.OpenForm "Property Form", acNormal, , , acFormEdit, , "Property ID"
I have tried the following sub but it errors on the RunSQL command:
Private Sub GetPropertyID()
'Create string variable (storage place)named mySQL
Dim mySQL As String
'Add lengthy SQL statement to mySQL in chunks.
mySQL = "SELECT [Property].[Property ID] FROM Property"
'Leading spaces below to ensure spaces between words.
mySQL = mySQL & " WHERE [House Name/ Number]=[Combo16] AND"
mySQL = mySQL & " [Address Line 1]=[Combo18] AND [Date record created]=[Combo20]"
'Hide warning messages provided by action queries:
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL
'Get warning messages back to normal:
DoCmd.SetWarnings True
End Sub
I want to open a second form at a particular address record that has been selected from a first form.
The first form offers three linked drop down combo lists, the first one for the House name/ number, the second for Address Line 1 and the third for date record created.
These are 3 fields from a table called Property whose primary key is [Property ID].
I need to retrieve the Property Id value in order that the following code should open my second form:
DoCmd.OpenForm "Property Form", acNormal, , , acFormEdit, , "Property ID"
I have tried the following sub but it errors on the RunSQL command:
Private Sub GetPropertyID()
'Create string variable (storage place)named mySQL
Dim mySQL As String
'Add lengthy SQL statement to mySQL in chunks.
mySQL = "SELECT [Property].[Property ID] FROM Property"
'Leading spaces below to ensure spaces between words.
mySQL = mySQL & " WHERE [House Name/ Number]=[Combo16] AND"
mySQL = mySQL & " [Address Line 1]=[Combo18] AND [Date record created]=[Combo20]"
'Hide warning messages provided by action queries:
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL
'Get warning messages back to normal:
DoCmd.SetWarnings True
End Sub