SunnyDayInside
Technical User
Hi!
I have a pop up form that allows two text string searches. The code is:
Private Sub cmdSearch_Click()
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
GcriteriaSec = cboSearchField1.Value & " LIKE '*" & txtSearchString1 & "*'"
If Not (Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True) Then
If Len(cboSearchField1) = 0 Or IsNull(cboSearchField1) = True Then
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_frmServiceForm.RecordSource = "select * from [Service Table] where " & GCriteria
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
Else
If Not (Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True) Then
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
GcriteriaSec = cboSearchField1.Value & " LIKE '*" & txtSearchString1 & "*'"
Form_frmServiceForm.RecordSource = "select * from [Service Table] where " & _
GCriteria & " And " & GcriteriaSec
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
End If
End If
End If
End Sub
This shows records on the main form that contain the text searched for. Then I have a button on the main form that opens a report.
Private Sub cmdReport_Click()
DoCmd.OpenReport "Daily Service report", acViewPreview, , GCriteria
DoCmd.OpenReport "Daily Service report", acViewPreview, , GcriteriaSec
End Sub
The problem I am having is that only the GCriteria and NOT GCriteiasec is being applied to the report. I need a solution where a user can apply none, one, or both of the criteria to the report. I'm being trying to do this for days now, any help is appreciated!!
I have a pop up form that allows two text string searches. The code is:
Private Sub cmdSearch_Click()
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
GcriteriaSec = cboSearchField1.Value & " LIKE '*" & txtSearchString1 & "*'"
If Not (Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True) Then
If Len(cboSearchField1) = 0 Or IsNull(cboSearchField1) = True Then
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_frmServiceForm.RecordSource = "select * from [Service Table] where " & GCriteria
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
Else
If Not (Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True) Then
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
GcriteriaSec = cboSearchField1.Value & " LIKE '*" & txtSearchString1 & "*'"
Form_frmServiceForm.RecordSource = "select * from [Service Table] where " & _
GCriteria & " And " & GcriteriaSec
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
End If
End If
End If
End Sub
This shows records on the main form that contain the text searched for. Then I have a button on the main form that opens a report.
Private Sub cmdReport_Click()
DoCmd.OpenReport "Daily Service report", acViewPreview, , GCriteria
DoCmd.OpenReport "Daily Service report", acViewPreview, , GcriteriaSec
End Sub
The problem I am having is that only the GCriteria and NOT GCriteiasec is being applied to the report. I need a solution where a user can apply none, one, or both of the criteria to the report. I'm being trying to do this for days now, any help is appreciated!!