Hi:
I have a continuous form with a recordsource having 4 text fields total. I'll call the recordsource fields Field1, Field2, .... In the form header I have 4 fields called field1filter, field2filter, ... When a header filter field is Null I want to show all records (with respect to that field), null or not null, but when there is text in the respective filter field I want to show only records that are "like" the filter, without the nulls. If I type text into a second "filter" field, I want to drill down the records to match the 2nd filter criteria as well, only records that match, no nulls with respect to the filtered fields. So, with text in two of the filter fields I want to show only records that have matching text in their respective fields.
The data is originally pulled from an Excel sheet and put into the record source table but I was extremely diligent with my append queries extracting this data from the Excel sheet to make sure I have Nulls and not zero length fields or spaces instead of text. I'm aware of the problems that null vs. 0 length or spaces can cause.
Here is the criteria used in the form's query for the 4 filtered fields:
Field1 criteria: Like "*" & [Forms]![<formname>]![field1filter] & "*" Or Is Null
Field2 criteria: Like "*" & [Forms]![<formname>]![field2filter] & "*" Or Is Null
Field3 criteria: Like "*" & [Forms]![<formname>]![field3filter] & "*" Or Is Null
Field4 criteria: Like "*" & [Forms]![<formname>]![field4filter] & "*" Or Is Null
Basically, with respect to each filter, if I type text into a header filter I want to show matching records without null values, but if the filter is null, I want to show all records, including nulls.
Hope I explained correctly, any help on this is greatly appreciated.
Charlie
i.e. ((like a or a= null) and (like b or b = null) .. etc.
the code would be similar to:
if filter1 <> "" then strcriteria = "Field1 ='" & filter1 & "'"
if filter2 <> "" then strcriteria = strcriteria & " AND Field2 ='" & filter2 & "'"
if filter3 <> "" then strcriteria = strcriteria & " AND Field3 ='" & filter3 & "'"
if filter4 <> "" then strcriteria = strcriteria & " AND Field4 ='" & filter4 & "'"