J
Jenny
HELP Please! I have a continuous form based on a qry called qry2009PO. I
want to be able to filter the records based on State (cboState) and County
(lstCounty) -which lstCounty is populated via an after update on cboState.
Both are text fields. Here is the code that I have. I get Runtime error
'2580' The record source 'Select * FROM 2009PO WHERE [State] like "CO*'"
specified on this form or report does not exist.
(CO is the state I chose in cboState).
*********code start**************
Private Sub cmdSearch_Click()
Dim strSQL As String
'If both State(cboState) and County (lstCounty) have data entered then
restrict using both.
If Not IsNull(Me!cboState) And Not IsNull(Me!lstCounty) Then
strSQL = ""
strSQL = strSQL & "SELECT * FROM 2009PO "
strSQL = strSQL & "WHERE [State] Like """ & Me!cboState & "*"""
strSQL = strSQL & " AND [County] Like """ & Me!lstCounty & "*"""
Me.RecordSource = strSQL
'If State(cboState) has data then restrict by State.
ElseIf Not IsNull(Me!cboState) Then
strSQL = ""
strSQL = strSQL & "SELECT * FROM 2009PO "
strSQL = strSQL & "WHERE [State] Like """ & Me!cboState & "*"""
Me.RecordSource = strSQL
End If
' Empty out the search criteria
Me!cboState = Null
Me!lstCounty = Null
End Sub
******************************************************
want to be able to filter the records based on State (cboState) and County
(lstCounty) -which lstCounty is populated via an after update on cboState.
Both are text fields. Here is the code that I have. I get Runtime error
'2580' The record source 'Select * FROM 2009PO WHERE [State] like "CO*'"
specified on this form or report does not exist.
(CO is the state I chose in cboState).
*********code start**************
Private Sub cmdSearch_Click()
Dim strSQL As String
'If both State(cboState) and County (lstCounty) have data entered then
restrict using both.
If Not IsNull(Me!cboState) And Not IsNull(Me!lstCounty) Then
strSQL = ""
strSQL = strSQL & "SELECT * FROM 2009PO "
strSQL = strSQL & "WHERE [State] Like """ & Me!cboState & "*"""
strSQL = strSQL & " AND [County] Like """ & Me!lstCounty & "*"""
Me.RecordSource = strSQL
'If State(cboState) has data then restrict by State.
ElseIf Not IsNull(Me!cboState) Then
strSQL = ""
strSQL = strSQL & "SELECT * FROM 2009PO "
strSQL = strSQL & "WHERE [State] Like """ & Me!cboState & "*"""
Me.RecordSource = strSQL
End If
' Empty out the search criteria
Me!cboState = Null
Me!lstCounty = Null
End Sub
******************************************************