reports requiring parameters which shouldn't

Z

zoohawk

Working with Access 2003.
I have two types of reports: one based on a parameter query, the other on a
select query limited by criteria. Parameters work fine in reports based on
paramQ's, but reports from select query still require parameters to be
defined. I can supply parameter information or not, neither affects the
record information in the report. If I do supply parameter info, this only
changes the report's title in print view as I have it doing for the paramQ
reports.

What do I need to do to better distinguish between the two types of reports
so that parameters are only required for reports based on paramQ's?
Any ideas as to why the program does this?
Thanks.
 
D

Duane Hookom

I try to avoid all use of dynamic criteria in report record sources. For
instance, if your report had a date field in its record source, there is
generally no reason to place parameters or criteria against the date field in
the query.

A better solution is to use a form with controls for entering all criteria.
Then use code to open the report with a where condition. For instance you can
use a command button with code behind it like:
Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " AND [DateField]>=#" & _
Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " AND [DateField]<=#" & _
Me.txtEndDate & "# "
End If
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
 
Z

zoohawk

Thanks, Duane. I'll try some version of that. Not looking for date ranges out
of these reports (at this level). But I think that will be useful in another
database I'm working on. Actually, it was a silly little thing: the report's
title was in a box formatted as text, not label. Noticed it as I was walking
out the door last night. Quick fix, works like it should now. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top