DROP DOWN QUERY HELP

  • Thread starter Thread starter Janeese
  • Start date Start date
J

Janeese

Currently I am using a parameter query that will pop up
and ask what category of things I'm looking for, example:
printers, monitors, servers, routers, etc.... All I have
to do is type in the first couple of letters, and it's
fine. Problem is, the boss want's me to have a drop down
to choose from all the different categories so you don't
have to know all of the categories..... I have never had
to do a pop up (parameter) query that had a drop down
list, I've already tried going into the build screen and
choosing Lookup, etc. not working it still comes up with
the old parameter query... PLEASE HELP.. LET ME KNOW IF
YOU NEED MORE INFO.

Thanks SOO MUCH,
Janeese
 
Janeese-

The best way is to get rid of the parameter and build a custom query by form
(QBF). You can bet dollars to donuts that your boss is going to want you to
add other criteria, and a QBF is the best way to handle that in the future.

Create an unbound form with the combo box on it. Add a command button that
runs code to check for a valid value, build a filter, and open the form or
report bound to your query with a WhereCondition parameter.

Let's say the name of the combo box is cmbCategory and the name of the form
that displays the information you want based on the category you select is
frmProducts. The code behind the command button will look something like:

Private Sub cmdGo_Click()
Dim strWhere As String
' Check for a category value
If Not IsNull(Me.cmbCategory) Then
' Build the filter
strWhere = "[Category] = '" & Me.cmbCategory & "'"
' Open the target form filtered
DoCmd.OpenForm frmProducts, WhereCondition:=strWhere
' Close this form
DoCmd.Close acForm, Me.Name
Else
' Didn't pick a category - display a message
MsgBox "You must select a category."
End If
End Sub

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
Back
Top