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

show specific criteria or all criteria

Status
Not open for further replies.

gray78

Programmer
Feb 3, 2005
78
US
I have several reports where I can set a specific parameter(dropdown box in a form) for a specific field and run the report. This works fine but if I want to leave the field blank and run the report for all data in the field where the parameter sits, I cannot do this, any suggestions?


Thanks
 
Try this...

Like iif(Forms!Formname!Objectname.value is null,"*",Forms!Formname!Objectname.value)

Hope this helps.
 
I prefer to remove the criteria from the report's record source. I use the control values in the Where clause of the DoCmd.OpenReport method. For instance
Code:
Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtStartDate) Then
    strWhere = strWhere & " AND [SaleDate]>=#" & _
        Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
    strWhere = strWhere & " AND [SaleDate]<=#" & _
        Me.txtEndDate & "# "
End If
'other sections of code
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere

I think this is much "cleaner".
There are some other references here faq703-2657, faq701-2328, and faq181-5497.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top