Hi
I have a form (Company) with a subform (Areas Inc Lay Company)
The subform has a combo box (country)
(record#) and (areas#) are the related fields in the underlying tables
With a command button (company_find_bareboat_operators_spain), on the main form I would like to filter records of company by the value of the combo box, in this example the value is Spain
Here is the buttons script;
-----------------------------
Private Sub company_find_bareboat_operators_spain_Click()
On Error GoTo Err_company_find_bareboat_operators_spain_Click
Dim stDocName As String
Dim strSQL As String
stDocName = "company_find_bareboat_operators_spain"
strSQL = "SELECT * FROM company INNER JOIN areas ON company.record# = areas.areas# WHERE ((areas.country)= 'Spain' )"
Me.RecordSource = strSQL
Exit_company_find_bareboat_operators_spain_Click:
Exit Sub
Err_company_find_bareboat_operators_spain_Click:
MsgBox Err.Description
Resume Exit_company_find_bareboat_operators_spain_Click
End Sub
--------------------------
When I click on the button I get 'Syntax error (missing operator) in query expression 'company.record# = areas.areas#'
I've been struggling with this for some time after several different approaches. So in addition to specific help with the above I'd also welcome comments on how I return a recordset of the main form by searching on subforms
I have a form (Company) with a subform (Areas Inc Lay Company)
The subform has a combo box (country)
(record#) and (areas#) are the related fields in the underlying tables
With a command button (company_find_bareboat_operators_spain), on the main form I would like to filter records of company by the value of the combo box, in this example the value is Spain
Here is the buttons script;
-----------------------------
Private Sub company_find_bareboat_operators_spain_Click()
On Error GoTo Err_company_find_bareboat_operators_spain_Click
Dim stDocName As String
Dim strSQL As String
stDocName = "company_find_bareboat_operators_spain"
strSQL = "SELECT * FROM company INNER JOIN areas ON company.record# = areas.areas# WHERE ((areas.country)= 'Spain' )"
Me.RecordSource = strSQL
Exit_company_find_bareboat_operators_spain_Click:
Exit Sub
Err_company_find_bareboat_operators_spain_Click:
MsgBox Err.Description
Resume Exit_company_find_bareboat_operators_spain_Click
End Sub
--------------------------
When I click on the button I get 'Syntax error (missing operator) in query expression 'company.record# = areas.areas#'
I've been struggling with this for some time after several different approaches. So in addition to specific help with the above I'd also welcome comments on how I return a recordset of the main form by searching on subforms