Report based on query depending on results of the query

A

Ang

I have a report of which the contents is based on a query. The query which
the report is based on is it self based on the results of another query. The
first query will always contain records however, the second query may not.
How do I tell the report that if the second query contains no records then
use the first query?

Can anyone help with this please?
 
F

fredg

I have a report of which the contents is based on a query. The query which
the report is based on is it self based on the results of another query. The
first query will always contain records however, the second query may not.
How do I tell the report that if the second query contains no records then
use the first query?

Can anyone help with this please?

Use an event on a form to open the Report.

Dim strFilter as String
If DCount("*","Query2")>0 Then
strFilter = "Query2"
Else
strFilter = "Query1"
End If

DoCmd.OpenReport "ReportName",acViewPreview,strFilter
 
A

Ang

Thank you for your help. It now opens the correct query if the first is
empty however it is not showing it in the report. I am getting an empty
report as well as the correct query (separate) but not in the report. The
data source of the report is the final query.
 

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