K
KPatel
I have a code that helps me to filter a report based on
criteria entered in a form. Here is a part of the code...
Dim strid As String
Dim strlast As String
Dim strfirst As String
Dim strfilter As String
If IsNull(Me.Id.Value) Then
strid = "Like '*'"
Else
strid = "='" & Me.Id.Value & "'"
End If
If IsNull(Me.Last.Value) Then
strlast = "Like '*'"
Else
Select Case Me.fraLastName.Value
Case 1
strlast = "Like '" & Me.Last.Value & "*'"
Case 2
strlast = "Like '*" & Me.Last.Value & "*'"
Case 3
strlast = "Like '*" & Me.Last.Value & "'"
Case 4
strlast = "= '" & Me.Last.Value & "'"
End Select
End If
If IsNull(Me.First.Value) Then
strfirst = "Like '*'"
Else
Select Case Me.fraFirstName.Value
Case 1
strfirst = "Like '" & Me.First.Value & "*'"
Case 2
strfirst = "Like '*" & Me.First.Value & "*'"
Case 3
strfirst = "Like '*" & Me.First.Value & "'"
Case 4
strfirst = "= '" & Me.First.Value & "'"
End Select
End If
strfilter="[C&R ID] " & strid & " AND [Last Name] " &
strlast & " AND [First Name] " & strfirst
This code would work fine if all the fields in a record
had data. But there are quite a few fields that have
been left blank and when I run the above code it does not
consider the records that have the blank fields.
For example,
If a record had the following values C&R ID-1001, Last
Name-Brown and First Name-not entered, and the filter
asked for records with last name Brown, the record for ID
1001 would not show up.
What condition should I give here to make sure that the
records with some blank fields are displayed as well if
they meet one or more of the filter criteria. Do let me
know if I have made myself clear enough. Thanks in
advance for whatever help anyone can provide.
Thanks
criteria entered in a form. Here is a part of the code...
Dim strid As String
Dim strlast As String
Dim strfirst As String
Dim strfilter As String
If IsNull(Me.Id.Value) Then
strid = "Like '*'"
Else
strid = "='" & Me.Id.Value & "'"
End If
If IsNull(Me.Last.Value) Then
strlast = "Like '*'"
Else
Select Case Me.fraLastName.Value
Case 1
strlast = "Like '" & Me.Last.Value & "*'"
Case 2
strlast = "Like '*" & Me.Last.Value & "*'"
Case 3
strlast = "Like '*" & Me.Last.Value & "'"
Case 4
strlast = "= '" & Me.Last.Value & "'"
End Select
End If
If IsNull(Me.First.Value) Then
strfirst = "Like '*'"
Else
Select Case Me.fraFirstName.Value
Case 1
strfirst = "Like '" & Me.First.Value & "*'"
Case 2
strfirst = "Like '*" & Me.First.Value & "*'"
Case 3
strfirst = "Like '*" & Me.First.Value & "'"
Case 4
strfirst = "= '" & Me.First.Value & "'"
End Select
End If
strfilter="[C&R ID] " & strid & " AND [Last Name] " &
strlast & " AND [First Name] " & strfirst
This code would work fine if all the fields in a record
had data. But there are quite a few fields that have
been left blank and when I run the above code it does not
consider the records that have the blank fields.
For example,
If a record had the following values C&R ID-1001, Last
Name-Brown and First Name-not entered, and the filter
asked for records with last name Brown, the record for ID
1001 would not show up.
What condition should I give here to make sure that the
records with some blank fields are displayed as well if
they meet one or more of the filter criteria. Do let me
know if I have made myself clear enough. Thanks in
advance for whatever help anyone can provide.
Thanks