Log in

View Full Version : [SOLVED:] how to construct a filter



daSpud
10-20-2018, 08:51 PM
This finds all the records with e_mail containing the letter "w".

Private Sub no_email_addr_Click() Dim DocName As String
DocName = "frmHomeOwner"
DocFilter = "[e_mail] like '*w*'"
Me.Filter = DocFilter
Me.FilterOn = True


End Sub

but this won't find the email addresses that are null:


Private Sub no_email_addr_Click() Dim DocName As String
DocName = "frmHomeOwner"
DocFilter = "[e_mail] like ''" ' that is a double single quote followed by an ending double quote
Me.Filter = DocFilter
Me.FilterOn = True


End Sub

I get no results and no error messages.

Thgouths on how I can get a list of records where there is no email address?

Thanks,

OBP
10-21-2018, 04:31 AM
Am I correct in assuming [e_mail] is a field in an Access dataset and you are setting the form filter?
If so you could try
DocFilter = "[e_mail] is null"

daSpud
10-21-2018, 04:51 AM
Am I correct in assuming [e_mail] is a field in an Access dataset and you are setting the form filter?
If so you could try
DocFilter = "[e_mail] is null"Your assumption is correct and your suggestion worked like a charm.

I have tried "= null" but never "is"

THANK YOU!