A family of Microsoft relational database management systems designed for ease of use.
Use Debug.Print to see what access is getting for strWhere.
Below is your code with the debug.print statement added.
Private Sub Search_Click()
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Prov ID
If Not IsNull(Me.[ProvID]) Then
'Create Predicate
strWhere = strWhere & " AND " & "qryMain.[Dr No] = " & Me.[ProvID] & ""
End If
' If State
If Not IsNull(Me.cboState) Then
'Add it to the predicate
strWhere = strWhere & " AND " & "qryMain.[STATE] = " & Me.[cboState] & ""
End If
Debug.Print strWhere
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse Providers", acFormDS, , strWhere, acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_Providers.Form.Filter = strWhere
Me.Browse_Providers.Form.FilterOn = True
End If
End Sub
After changing the code, open the form normally and Choose a state and then open the immediate window to see strWhere.
The quotes used in strWhere for State - a text field - don't look quite right in your post.
Try
strWhere = strWhere & " AND " & "qryMain.[STATE] = '" & Me.[cboState] & ""
Thanks - that did it. I forgot about the single quotes!!