Good morning:
I have a fundamental question about "requery" on a form. Apparently, the "REQUERY" does not give me the expected results. I'm sure the answer is staring me right in my face, but seems like I need a 2nd set of eyes to figure out the answer.
Attached is a DB containing a search form/DB with 50 sample records. Allow me to provide some background first.
Background:
- Upon opening the DB, the search form opens by default.
- In the top left, I have a list box that displays all available jobs. Once I click on any of these, the large listbox (bottom) is updated accordingly.
- In addition to the listbox "Search by Job Title", I also have an unbound textbox "Search by Keyword"... in yellow (top right).
- If I were to type, e.g., "snake" (I randomly generated 50 keywords), the large listbox at the bottom is filtered and now shows 3 jobs matching the keyword criteria.
... so far so good... no changes are required up until this point.
Existing process:
1. If I select "Business Analyst (7)", 7 jobs are displayed.
2. If I select any other job, the listbox gets updated accordingly.
3. Just like #2, the large (results) listbox also gets updated when I type into the yellow texbox any existing keyword (i.e., randomly selected animal in this case).
Underlying issue:
- If I chose a value from the listbox but then want to display ALL RECORDS (50) records again, I currently have to type any characters (e.g., XYZ) AND THEN "backspace" on my keyboard to show all 50 records.
- To prevent the need for having to type any characters into the yellow unbound textbox AND then having to BACKSPACE (on my keyboard), I added an option to my "Actions" listbox ("Clear Search Criteria").
The associated VBA for clicking this item is as follows:
So, while the command "txtSearch.Value = Null" removes any values (ultimately, the same as the manual BACKSPACE), the line "Me.lstBox.Requery" does NOT requery/refresh the large listbox and show all 50 records again.Code:'Clear Search Criteria (listbox and combo) If Me.lstActions = "Clear Search Criteria" Then txtSearch.Value = Null lstSearch.Value = Null Me.lstBox.Requery End I
Why is that? Is there another command that I need to use to requery/refresh control "lstBox"?
I'd welcome any suggestions/recommendations to solve this small issue. Thank you!
Cheers,
EEH