Unanswered: Listbox as Parameter Query in a Report or Query
I have table set up that is called "Accounts Payable Check Listing" which lists all the checks my company has paid out. I also have a query that is named "AP checks" that is based off of the one table "Accounts Payable Check Listing". In the query itself, I have one parameter query setup that prompts you to enter in the Vendor Name.
If you type in the exact name of the vendor, the query will return data.
I also have a Report that runs off of the Query mentioned above, and whenever I run the report, just like query will....it prompts you for the vendor name. The problem is.....if you don't know the vendor name exactly as it is in the table....the query or report returns nothing back.
My question: Is there a way to have a drop down list or LISTBOX in the query or the report. I know you can do listboxes in Forms. But I've tried all different ways to get this to work.
Ideally, I'd like for a user to double click or run this report, have it prompt you for the "Vendor Name" field, once you select it in the listbox...it will run the report and give you a list of checks for that particular Vendor name you selected in the listbox prompt.
Is this possbile? Keep in mind....I am only a beginner in Visual Basic.
Thanks for your help. My Controller of my company is waiting for me to finish this project and she is stressing me out
Thanks for any help you can give me in this matter.
Can you post this on the site so I can see how this was done? I am working on a project that requires a search on a field with results to go to report, that needs to have a drop down box with choices to search.
The free downloadable sample database at www.bullschmidt.com/access uses the query by form concept so that on the invoices dialog one can optionally choose a rep, a customer, and perhaps a date range, click on a button that says "Input," and then have the invoice form open up showing all the invoices that match the criteria.
And here is how the query by form concept can work.
On the invoices dialog there are the following controls:
InvDateMin with DefaultValue of =DateSerial(Year(Date())-1,1,1)
InvDateMax with DefaultValue of =Date()
InvRepNum with DefaultValue of *
InvCustNum with DefaultValue of *
Also on the invoices dialog there is a command button called cmdInput to open the invoices form with the following code behind the OnClick property:
And of course there could be a button to open a report the same way:
DoCmd.OpenReport "rptInv", acViewPreview
The invoices form (frmInv) has RecordSource property of qryInv.
And the qryInv query's criteria for the InvDate field has:
Between [Forms]![frmInvDialog]![InvDateMin] And [Forms]![frmInvDialog]![InvDateMax]
And the qryInv query's criteria for the RepNum field has:
And the qryInv query's criteria for the CustNum field has:
One related point is that you probably wouldn't want to allow blanks (i.e. Nulls) in fields that are going to be used with Like in any criteria for that field. Otherwise the blanks wouldn't be shown. And to counter that you might consider creating the query's SQL statement dynamically so that the criteria on a particular field isn't used unless needed.