Parameter Query

DarkProdigy

Registered User.
Local time
Today, 07:08
Joined
Jan 9, 2006
Messages
91
Hey guys

I was wondering how I would go about making it so that a query will run or not run based on the input from a combo box.

I have a form with several combo boxes. And a couple of these controls a query that I would like to be optional. Right now it runs no matter what the input in the combo box, but I would like it to run based on the selection of the box (ie. "Yes" or "No" type input)

Your help on this is much appreciated

Nathan
 
if the query runs after the combo box has been updated then
in the after update event check whic value has been selected andthen either run or not run the query
 
Smart said:
if the query runs after the combo box has been updated then
in the after update event check whic value has been selected andthen either run or not run the query
that's not quite what I'm looking for

the combo box will be updated no matter what. In the combo box will be a Yes/No type selection, and based on this input, I want it either run, or not run the query
 
Smart said:
if the query runs after the combo box has been updated then
in the after update event check whic value has been selected andthen either run or not run the query
ok nevermind, I misread what you typed

this is what I'm looking to do, but I don't know the coding as I've had no experience with VBA. If someone could help me out with it that would be great

I would assume it would be an If/Then type statement
 
In the AfterUpdate event for the combo box put

If Me.CmbName = -1 Then
DoCmd.OpenQuery "QueryName", viewtype
End If
 
ok

so if I wanted it to go off something other than "yes" or "no" but to choose from 2 selections but I want it to run in a similar manner. how would I go about doing that?
 
If Me.cmbName = "Value" Then
Do whatever
End If

If the value is a number, however, you dont need the " " around the Value.
 
excellent

thank you d00ku, I will see if I can work this out with what you've given me
 
what error do you get (if any)?

if the combobox is on a subform then you need to reference that as well (instead of Me.)
 
it gives me "Compile error: Variable not defined" and highlights "viewtype"
 
ah right, you need to replace "viewtype" with the actual view type you want your query to be opened in.

Replace it with acViewNormal and that should do the trick.
 

Users who are viewing this thread

Back
Top Bottom