Conditional Query Data in a Report

  • Thread starter Thread starter silva
  • Start date Start date
S

silva

Is there a way to include the search criteria from a query in a report?

More specifically, I use a date condition in a query to produce a report,
and I'd like to add the date entered in the message box to the report. Is
there a way to do that?
 
If you are trying to do this using only a query and a report, I'm not
familiar with a way.

If you want to do this, the one way I know of is to use a form to "collect"
the criteria that your query uses, then refer to the value entered in the
form from within the report.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Is there a way to include the search criteria from a query in a report?

More specifically, I use a date condition in a query to produce a report,
and I'd like to add the date entered in the message box to the report. Is
there a way to do that?

I think you mean you are using a parameter prompt in the query to
filter the records and you wish to show the parameter dates in the
report.
If that is correct, then, assuming the query criteria was:
Between [EnterStartDate] and [EnterEndDate]
add an unbound text control to the report Header.
Set it's control source to:

="For sales between " & [EnterStartDate] & " and " & [EnterEndDate]

The text within the brackets must be identical to the bracketed text
in the query parameter.
 
You can use calculated fields like this --

Report Start: [EnterStartDate]
Report End: [EnterEndDate]
Or like this --

Report Period: [EnterStartDate] & " through " & [EnterEndDate]

The text within the brackets must be identical to the bracketed text
in the query parameter.


As fredg said the text within the brackets must be identical to the
bracketed text in the query parameter.
 
Yes, this is exactly what I was looking for. Sorry, I forgot the term
"parameter", I suppose that would have helped clarify what I was asking. But
yes, this fits what I was looking for perfectly.

fredg said:
Is there a way to include the search criteria from a query in a report?

More specifically, I use a date condition in a query to produce a report,
and I'd like to add the date entered in the message box to the report. Is
there a way to do that?

I think you mean you are using a parameter prompt in the query to
filter the records and you wish to show the parameter dates in the
report.
If that is correct, then, assuming the query criteria was:
Between [EnterStartDate] and [EnterEndDate]
add an unbound text control to the report Header.
Set it's control source to:

="For sales between " & [EnterStartDate] & " and " & [EnterEndDate]

The text within the brackets must be identical to the bracketed text
in the query parameter.
 

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

Back
Top