Search form not returning records with blank fields

crystal2000a

New member
Local time
Today, 07:25
Joined
Jul 23, 2012
Messages
3
Hi Experts,

I'm creating a search form to filter out data based on certain inputs. My VBA code looks like:

Code:
Private Sub Command18_Click()
On Error GoTo errorcatch

Me.Filter = "([Experiments.Log] Like ""*" & Me.Text21 & "*"") AND ([Expdate] Like ""*" & Me.Text22 & "*"") AND ([BaseSolution] Like ""*" & Me.Text24 & "*"") AND([AddCom] Like ""*" & Me.Text25 & "*"") AND ([Test] Like ""*" & Me.Text26 & "*"") AND ([Plan] Like ""*" & Me.Text23 & "*"")"


Me.FilterOn = True
Exit Sub
errorcatch:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description

End Sub

However, the output does not include records where other fields are blank. I have read that I may need to use Is Null but am not sure how to. Any help would be appreciated!!
 
Try this code..
Code:
Me.Filter = "(([Experiments.Log] Like ""*" & Me.Text21 & "*"") OR ([Experiments.Log] Is Null)) AND " & _
            "(([Expdate] Like ""*" & Me.Text22 & "*"") OR ([Expdate] Is Null)) AND " & _
            "(([BaseSolution] Like ""*" & Me.Text24 & "*"") OR ([BaseSolution] Is Null)) AND " & _
            "(([AddCom] Like ""*" & Me.Text25 & "*"") OR ([AddCom] Is Null)) AND " & _
            "(([Test] Like ""*" & Me.Text26 & "*"") OR ([Test] Is Null)) AND " & _
            "(([Plan] Like ""*" & Me.Text23 & "*"") OR ([Plan] Is Null))"
 
Thank you!! It worked!!
 

Users who are viewing this thread

Back
Top Bottom