Multiple query criteria from list box

S

SteveR

Hello, I have a list box with fields [empID] and [VisitID] and a query which
uses these two criteria to extract data from a table listing all the visits
an employee is responsible for. I can and have used the double click event
on list boxes to open a form tied to a query using criteria off of a list box
before but never more than one criteria. Can it be done? I'm not having any
luck with my experiments.

Thanks for the help!!
 
O

Ofer

You can pass more then one criteria

' If the fields are numbers
docmd.OpenForm "FormName",,,"[empID] =" & Me.ListName.column(0) & " AND
[VisitID] = " & Me.ListName.column(1) ' the column number it for each
column in the list start with 0

' If the fields are string
docmd.OpenForm "FormName",,,"[empID] ='" & Me.ListName.column(0) & "' AND
[VisitID] = '" & Me.ListName.column(1) & "'"
 
S

SteveR

This works great! Getting all of the quotation marks correct takes some
doing though. Thanks for the help!

Ofer said:
You can pass more then one criteria

' If the fields are numbers
docmd.OpenForm "FormName",,,"[empID] =" & Me.ListName.column(0) & " AND
[VisitID] = " & Me.ListName.column(1) ' the column number it for each
column in the list start with 0

' If the fields are string
docmd.OpenForm "FormName",,,"[empID] ='" & Me.ListName.column(0) & "' AND
[VisitID] = '" & Me.ListName.column(1) & "'"


--
In God We Trust - Everything Else We Test


SteveR said:
Hello, I have a list box with fields [empID] and [VisitID] and a query which
uses these two criteria to extract data from a table listing all the visits
an employee is responsible for. I can and have used the double click event
on list boxes to open a form tied to a query using criteria off of a list box
before but never more than one criteria. Can it be done? I'm not having any
luck with my experiments.

Thanks for the help!!
 
Top