One Report - Two Queries? (1 Viewer)

JeffBarker

Registered User.
Local time
Today, 04:39
Joined
Dec 7, 2010
Messages
130
Hey guys,

Just a quick one - just wondering if anyone can tell me if it's possible to open a report with one of two different queries, depending on where it's opened from?

So if it's opened from Form A, Query A gets loaded as the recordsource, but if it's opened from Form B then it gets loaded with Query B.

If it is possible, how would one go about doing this?

Many Thanks in advance!

J.
 

winshent

Registered User.
Local time
Today, 04:39
Joined
Mar 3, 2008
Messages
162
In your code that opens the report:

Code:
  If monkey Then
    DoCmd.OpenReport "Report", acViewPreview, , , , "qryMonkey"
  Else
    DoCmd.OpenReport "Report", acViewPreview, , , , "qryBanana"
  End If

In the Open event of the report:

Code:
Private Sub Report_Open(Cancel As Integer)
  Me.RecordSource = Me.OpenArgs
End Sub
 

JeffBarker

Registered User.
Local time
Today, 04:39
Joined
Dec 7, 2010
Messages
130
Ah, thanks winshent - muchly appreciated! :)
 

Users who are viewing this thread

Top Bottom