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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create form to select criteria for query/report

Status
Not open for further replies.

diddydustin

Programmer
Jul 30, 2002
181
US
Hey guys,

I was wondering if anyone could help me in the right direction. I have a query that returns many results. I would like to create a form that has 4-5 textboxes/comboboxes that are used to select the criteria for the query. I guess they would be establishing a filter for the query and then opening it. However, I would like the form controls to have the option to be null, as the user may not want to select all the criteria at all times. (For example, they may just want a date range, or they may want a date range plus a price). I think this should be very simple but I can't seem to find an example anywhere. If anyone could point me in the right direction of what my controls need to be doing, it would be great.

I am going to have 4-5 controls and a submit button. So the event should be for the OnClick of the submit button.

Thanks guys!
Dustin
 
Hi
There are lots of example in the FAQs in these fora. Try this for example:
How to dynamically build a query from controls on a form faq701-2328
It should get you started. :)
 
Also, check out this FAQ faq181-5497 It contains a function that loops thru all of the controls on your Report Criteria form and builds the Where clause for you. It works for single and multi-select list boxes, combo boxes, text boxes, date ranges, options groups, and check boxes. You only have to do 3 things to make it work.

1. Create a new module and copy and paste the function from the FAQ into your new module.
2. Set the tag properties of each of your controls as specified in the documentation within the FAQ. This is the key to making it work. I would suggest setting the tag property of one of your combo boxes or text boxes and placing a temporary button on your form. In the onclick event of this temp button, add this code: Msgbox BuildWhere(Me)
3. Open the report as specified in the documentation within the function.

If you don't understand the code in the function BuildWhere. Don't worry about it. Just use it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top