Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Values in a List Box to Select Records

Status
Not open for further replies.
Feb 6, 2003
48
US
Good Morning-

I have a database that is used by our Mat Mgt Dept for printing stock labels. Currently the user will enter criteria such as facility and inventory to generate a list of stock labels to be printed. Now the users would like the ability to enter one or more indivual stock numbers as well. I will need to include an "ALL" option as well.

I thinking I need to use a list box to allow the users to select the stock number, but I do not know how to incorporate this into the form so that the appropriate stock numbers are selected. I do have some VBA experience but this task is something I've not done before. Thanks in advance for any help.
 
Check out this FAQ faq181-5497. The header of the code will explain how it works. Basically, create a new module and then copy and paste the code from the FAQ into the new module and save it.

Assuming you have a report created whose RecordSource contains stock numbers, create a form and add a combo box that lists the stock numbers from which to choose. Set the tag property of the combobox so it looks something like this: Where=StockNumber.long. Then add a button on the form and on the OnClick event add code something like this: DoCmd.OpenReport "reportname",,,BuildWhere(Me).

That's it. The report will open and only display records whose stock numbers were ones selected in the combo box.

The BuildWhere code works for date ranges, text box, etc. Again, the header of the code will explain how to set it up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top