Full Version: Filtering form records with a combobox
UtterAccess Forums > Microsoft® Access > Access Forms
I am filtering form records using an unbound combobox, by setting the form's query based on the unbound combobox.
This works fine, so long as one specific value is selected. If nothing is selected no records show up.
Is there a way to have a selection in the combobox that would not filter that field (show all records)?
Welcome to UA Kirk
Try using the following in your query criteria
Like YourcomboName & "*"
Adding to dallr's information ...
allr's method will work, however, you MAY get results you do not want, since the "*" is ALWAYS tagged to the end of the value in the combo... For example is you select/type "Stan" in the combo ..
Like 'Stan*' ... will be your criteria and return Stan, Stanley, Stanford, etc ...
So, if that is undesirable for you, then do this:
LIKE NZ(YourControlName,"*") ... Use the same example:
Like "Stan" ... will be your criteria
With either method you choose it is advisable to convert your nulls from the field you are using to compare the criteria ...
Expr: Nz(PossibleNullField,"")
Criteria: Like Nz(YourConrolName,"*")
Adding even more to the discussion, if any of the values in your table happen to be NULL, they won't be picked up by the "*" wildcard. To easily correct this, in your query, substitute:
ieldname: NZ(tablename.fieldname,"")
for the field expression, and use:
LIKE NZ(Forms!formname!controlname,"*")
for your criteria.
Here's how I do it. I want the user to select something so that it is an action on his part:
See the attached.
Hey Kirk, I am having trouble doing the same thing you are. However my situation is a little different. What I have is a search form. On the search form I have a text box and a list box. Both are unbounded. The user will type a name in the text box and all the people with that name will appear in the list box.
I have been able to get this working, however one problem that I am having is that everytime I open the Search form, it prompts with with Enter Parameter Value box. What i want is it to go directly to the search form and ahve the user enter the search key in the text box not in the Enter Parameter Value box that it prompts me with.
Any help with this will be much appreciated.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.