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

Populating a query criteria w/a combo box

Status
Not open for further replies.

jmr9999

MIS
Sep 19, 2002
18
I am trying to create a query that has a combo box incorporated into it. For example, I only want to get data from CA from a States table in my query. When the individual runs this report (using the appropriate query) a combo box would appear listing the STATES. Is this possible?
 
I'll assume you're using a form. Place a combo box (cboState)with a label that says 'Select State'. You can pick the combo box value up and use it to refine both the data diplayed and the report.

Private Sub cboState_Click()
On Error GoTo NoState
Dim strState as String
strState = Me![cboState]
Me.Filter = "((qryUsed.State = '"&strState&"'))" 'This assigns the filter
Me.FilterOn = True 'This turns the filter on,use this if you want to filter the form and display the results. Otherwise, just assign the Me.Filter and use it when you open the report (see below)
Exit Sub

NoState:
If Me![cboState] = Null Then Exit Sub
End Sub


DoCmd.OpenReport stDocName, acPreview, , Me.Filter

Have a happy programming day!
L
 
I just posted a similar question wanting the query itself to provide a selection for the user...not call the values from a table or call a form with a combo box attached. Is there any way you know of to put; inside the [ ] I suppose, items to be chosen? Deon Cranford
dc2@scotlandhealth.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top