B
BillA
This code is to create a filter string for Allen Browne’s search form. I
would like to add code that would look at a number of checkboxes and, if none
were checked, bypass or ignore their corresponding “If†conditions, possibly
using a “GoTo†statement? In other words; if a checkbox (or checkboxes) =
True Then execute otherwise skip this code continue with the procedure.
Here is a snippet of my code:
If (Me.chk24A) = True Then
strWhere = strWhere & "([24A]= True) AND "
ElseIf Me.chk24A = 0 Then
strWhere = strWhere & "([24A] = False) AND "
End If
If (Me.chk24B) = True Then
strWhere = strWhere & "([24B]= True) AND "
ElseIf Me.chk24B = 0 Then
strWhere = strWhere & "([24B] = False) AND "
End If
If (Me.chk67E) = True Then
strWhere = strWhere & "([67E]= True) AND "
ElseIf Me.chk67E = 0 Then
strWhere = strWhere & "([67E] = False) AND "
End If
……………………….
If Not IsNull(Me.txtRStartDate) Then
strWhere = strWhere & "([DateReceived] >= " &
Format(Me.txtRStartDate, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtREndDate) Then 'Less than the next day.
strWhere = strWhere & "([DateReceived] < " & Format(Me.txtREndDate +
1, conJetDate) & ") AND "
End If
………………………
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to
Immediate Window (Ctrl+G).
'Debug.Print strWhere
End If
End SubThank you for any assistance.
Bill
would like to add code that would look at a number of checkboxes and, if none
were checked, bypass or ignore their corresponding “If†conditions, possibly
using a “GoTo†statement? In other words; if a checkbox (or checkboxes) =
True Then execute otherwise skip this code continue with the procedure.
Here is a snippet of my code:
If (Me.chk24A) = True Then
strWhere = strWhere & "([24A]= True) AND "
ElseIf Me.chk24A = 0 Then
strWhere = strWhere & "([24A] = False) AND "
End If
If (Me.chk24B) = True Then
strWhere = strWhere & "([24B]= True) AND "
ElseIf Me.chk24B = 0 Then
strWhere = strWhere & "([24B] = False) AND "
End If
If (Me.chk67E) = True Then
strWhere = strWhere & "([67E]= True) AND "
ElseIf Me.chk67E = 0 Then
strWhere = strWhere & "([67E] = False) AND "
End If
……………………….
If Not IsNull(Me.txtRStartDate) Then
strWhere = strWhere & "([DateReceived] >= " &
Format(Me.txtRStartDate, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtREndDate) Then 'Less than the next day.
strWhere = strWhere & "([DateReceived] < " & Format(Me.txtREndDate +
1, conJetDate) & ") AND "
End If
………………………
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to
Immediate Window (Ctrl+G).
'Debug.Print strWhere
End If
End SubThank you for any assistance.
Bill