Union query works but will not filter report. (1 Viewer)

Stang70Fastback

Registered User.
Local time
Yesterday, 21:23
Joined
Dec 24, 2012
Messages
132
Just as the title suggests, I've got a problem. I have a report with the record source based off of "SOURCEDATA."

Then I've got a union query that merges two other queries, which themselves are based off of the "SOURCEDATA" query. So everything is based off of the same source.

The report, when I pull it up without any filters works fine and shows ALL the data. The union query, when I open it on its own, also works fine and shows exactly what I want it to show. However, when I apply it to the Report, nothing changes. I still see ALL of the data. Interestingly, the intermediate queries that the union compares can be applied to the report and that works and shows just what I would expect.

Is there something special about union queries that they can not be used to filter report data? I don't get any errors, but I just don't get any effect of applying it to the report.

If I try to make the report's record source the union query itself, Access seems to get stuck in some sort of loop that slows everything down significantly and I have to [slowly] set the record source back to something else to get it to stop locking up. Is this any sort of hint as to what my issue is?
 
Last edited:

apr pillai

AWF VIP
Local time
Today, 06:53
Joined
Jan 20, 2005
Messages
735
It looks like the Union Query enters into some infinit loop and make the system hang.

I think, a better approach is to create a Report Table out of the Union Query, by running a make-table query (through a macro) and use the table as Record Source to the Report. The Report also can be opened through the macro in second step in the macro. Let the macro run through a Command Button-Click Event Procedure.

If you would like to know few things about the Union Query then find it from here.
 
Last edited:

Stang70Fastback

Registered User.
Local time
Yesterday, 21:23
Joined
Dec 24, 2012
Messages
132
Would it be possible for you to explain in a bit more detail exactly what you mean by a Make-Table Query? It sounds like you are suggesting I turn the Query into a table and use that data instead. That sound like it might work, but I'm not sure how to go about it.

Thanks for the help!
 

apr pillai

AWF VIP
Local time
Today, 06:53
Joined
Jan 20, 2005
Messages
735
  1. Create a make-table query using Union Query as Data Source, run it and create the output table, say tblReport.
  2. Design the Report using tblReport as Record Source or if you need further filtering the records from tblReport then create a Select Query and use it as report source.
  3. Open the Report in PrintPreview.

Step 1 & 3 must be repeated every time the report source data changes in the Union Query. Running these two actions manually every time is not advisable.

These two actions (1. opening the make-table Query, 2. Opening the Report) can be put in a macro (sample image of a macro is attached) and run the macro from a Command Button Click Event Procedure on the Form, whenever the report source data changes.

In fact you can put two command buttons on the Form, one for re-running the report through the macro, and another one to open the existing report directly in PrintPreview mode.
 

Attachments

  • macro_image.jpg
    macro_image.jpg
    50.8 KB · Views: 82

Users who are viewing this thread

Top Bottom