I have a form in my MSAccess application that searches the master database across 4 fields. You can fill in as little into 1 field or as much into all 4 fields or anywhere in between that you desire.
The database fields to be searched are:
- rmanbr - Integer
- custNbr - Integer
- customername - Text
- invcmnbr - Text (as it will store either invoice numbers (######) or credit memo numbers (CM-####)
The form has 4 fields in which to sort by respective of the above:
- SrchRMANbr
- SrchCustNbr
- SrchCoName
- SrchInvCMNbr
I have a query that selects all of the data to be displayed. The 4 fields to be filtered are filled with Like "*" & [forms]![RMA Search]![FieldName] & "*"
into the Criteria section of the Query Builder for that specific query
The rmanbr and customername fields in the database will never be NULL, they're not allowed to be. But, the invcmnbr and custnbr can be and frequently are NULL with no values.
So, my search form is the 4 Srch
fields listed above where users can enter in the stuff they want to filter by. There is a listbox that is designed to start filtering the results based on the "On Change" of the text boxes that the user will use to filter results. The user then selects the record and goes on his merry way.
However, the ListBox is filtering out all NULL Values from the two fields that can be NULL, whether or not the corresponding Srch
box is blank, so the rows with NULL either in the custnbr
or invcmnbr
fields is not showing up in the listbox.
I've tried stuffing a Is Null
into the "Or" Criteria of the query I'm using to populate the listbox. I tried it in the second line of the Query Builder Criteria section "Is Null" and this showed all the rows if they had NULL values even if I entered in a number into SrchRMANbr
field. Ideally entering in an RMANbr would filter by RMANbr whether or not NULL values existed, since this is a unique value (there can only be 1 of any RMANbr in the master table). If I put after the Like "*" & [forms]![RMA Search]![FieldName] & "*"
in the criteria (on the same line) Or Is Null
it would get me closer, but any search into the SrchCustNbr
or SrchInvCMNbr
fields would produce the filtered result as well as all the NULL values for that field.
So, in short, I require a way to:
1) Show all of the values, NULL or not, in the listbox before a user starts to enter data in any field.
2) Filter away the NULL values when a user starts to enter data into the SrchCustNbr
or SrchInvCMNbr
field.
3) Keep the NULL Values up but filter by RMA Nbr
correctly when the user starts to enter an number into the SrchRMANbr
(as this is the master record, this is as specific as it can get)
I hope I'm conveying the issue correctly. Let me know if you need any additional information to assist me in solving my issue.