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!

opening query based on parameter

Status
Not open for further replies.

amberlynn

Programmer
Dec 18, 2003
502
CA
Hello.
How can I open a query based on a combobox value selected on a form?
Thanks in advance!
Amber
 
If the value from the combobox is to be part of the Criteria/Where Clause, put it there as such:

[Forms]![YourFormName]![YourComboboxName]

 
To expand on sxschech's response, here's the how to do that, just in case:

In your query in design mode, put your code matching his example in the [blue]Criteria[/blue] section for whatever field you are wanting to compare it against.

Then in the AfterUpdate Event for your combo box, you can put the code:
Code:
Private Sub MyComboBox_AfterUpdate()
  DoCmd.SetWarnings = False
  DoCmd.OpenQuery "MyQuery"
  DoCmd.SetWarnings = True
End Sub

The SetWarnings part will only be useful if you're running a query that will create, change, or delete a table..

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top