I am trying to create a filter based on tblStoredStudies.site. I have created an unbound combo with the site names able to be selected. I have created a Filter button that when click should filter the results in my subform to show only the sites that match the selection in the combo box. When I click the Filter button I am getting "Syntax error in FROM clause". The code for the filter button is as follows
Private Sub Filter_Click()
On Error GoTo Err_Filter_Click
Dim strSQL As String, strWhere As String
'*** create the query based on the information on the form
strSQL = "SELECT tblStoredStudies.protocol_number, tblStoredStudies.therapeutic_area, tblStoredStudies.sponsor, tblStoredStudies.cro, tblStoredStudies.pi, tblStoredStudies.site, tblStoredStudies.storage " _
& " FROM tblStoredStudies "
strWhere = "site=" & Combo0
strSQL = strSQL & strWhere
'MsgBox strSQL
'*** change the recordsource of the subform
Me.sfrmStoredStudiesList.Form.RecordSource = strSQL
Me.sfrmStoredStudiesList.Form.Requery
RemoveFilter.Visible = True
RemoveFilter.SetFocus
Exit_Filter_Click:
Exit Sub
Err_Filter_Click:
MsgBox Err.Description
Resume Exit_Filter_Click
End Sub
Can anyone tell whats wrong?
Thank you
Private Sub Filter_Click()
On Error GoTo Err_Filter_Click
Dim strSQL As String, strWhere As String
'*** create the query based on the information on the form
strSQL = "SELECT tblStoredStudies.protocol_number, tblStoredStudies.therapeutic_area, tblStoredStudies.sponsor, tblStoredStudies.cro, tblStoredStudies.pi, tblStoredStudies.site, tblStoredStudies.storage " _
& " FROM tblStoredStudies "
strWhere = "site=" & Combo0
strSQL = strSQL & strWhere
'MsgBox strSQL
'*** change the recordsource of the subform
Me.sfrmStoredStudiesList.Form.RecordSource = strSQL
Me.sfrmStoredStudiesList.Form.Requery
RemoveFilter.Visible = True
RemoveFilter.SetFocus
Exit_Filter_Click:
Exit Sub
Err_Filter_Click:
MsgBox Err.Description
Resume Exit_Filter_Click
End Sub
Can anyone tell whats wrong?
Thank you