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

Parameter query using a form.

Status
Not open for further replies.

tonyblazek

Technical User
Mar 22, 2001
10
US
Hello all, new user here. What is the best way to do this, I need a form with 3 variables selected from combo boxes to launch a query. The out of the box parameter query doesn't gives you any predefined variable choices. Thanks, Tony
 
Are you asking how to limit the query's results based on what you have selected in the form?
If so...
In the design view for your query, you can place values of controls from forms in the criteria. Right click in the 'criteria' box and choose 'build'. This is a neat tool to use. You can navigate the tree structure of the expression builder to find the form and the control whose value you wish to use to limit the results of your query.
 
THANKS!!, it works fine. How would you go about making the query work with one of the vaules missing? Right now Access needs all three to find anything. Thanks, Tony
 
You may want to look into the 'immediate if' and the 'is null'. Here's the help file example of iif.

You can enter the following expression in the ControlSource property of a calculated control.
= IIf([OrderAmount] > 1000, "Large", "Small")

 
Tony:

If you have used VB code you might try this.

When I set up forms such as this, I pass the selected values from the combo boxes (after update event) to text boxes.

The code is simply: txtSelect1 = cboSelect1 (you may need to tinker with this if the bound column of the combo box is not the actual value you want to search for).

In the on click event for the command button that runs the query, I test the value of the combo box and if it is null I set the value of the related text box to "Like *".

The code is: If IsNull(cboSelect1) then txtSelect1 = "Like *"

I then reference the text boxes in the query rather than the combo boxes.

Hope this helps. Let me know.
Larry De Laruelle
larry1de@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top