Passing parameters to a query

J

jsccorps

Want to enter either a particular Manager Number or leave blank (when left
blank, I want to pull all Managers).

I can pass a particular Manager Number to a query and get info on that
manager - this works fine. How can check for a blank entry, and then have
the query output info for all managers?
 
J

John Vinson

I can pass a particular Manager Number to a query and get info on that
manager - this works fine. How can check for a blank entry, and then have
the query output info for all managers?

Use a criterion like

=Forms!NameOfForm![Manager Number] OR Forms!NameOfForm![Manager
Number] IS NULL

John W. Vinson[MVP]
 
R

Randy Wayne

It depends how you are passing the parameter.

If you are using the WHERE clause you can do the following:

Add a WHERE clause at the beginning that is something that is always true -
like WHERE 1 = 1. Then pass this along as your WHERE clause when the
textbox, combobox, etc is NULL.

How are you passing the parameter?

Randy
 
J

jsccorps

Passing the parameter using the following format:

=Forms!NameOfForm![Manager Number]
 
P

Powderfinger

Your query is probably the Record Source for a form or report. You are
better off taking the WHERE clause out of the query , so that the query
displays all records. Then open the form or report with a criteria , such
as:

Dim strCriteria As String
If Not ISNull(Me.[Manager Number]) Then
strCriteria = "[Manager Number] = " & Me.[Manager Number]
End If
DoCmd.OpenReport "ReportName", acViewNormal, , strCriteria




jsccorps said:
Passing the parameter using the following format:

=Forms!NameOfForm![Manager Number]

 
Top