By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

Which form opened this report?

Expert 100+
P: 218
Hi,

Being very dumb today!

I need to know, in VBA code, which form was used to call a report (using DoCmd.OpenReport)

Must be some sort of method or property to do this???

TIA

Steve
Jan 11 '07 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,638
Hi,

Being very dumb today!

I need to know, in VBA code, which form was used to call a report (using DoCmd.OpenReport)

Must be some sort of method or property to do this???

TIA

Steve
Use the OpenArgs Property of the OpenReport Method as in:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2.  
  3. stDocName = "rptEmployee"
  4. DoCmd.OpenReport stDocName, acPreview, , , acWindowNormal, "My Form Name"
Then, in the Report's Open() Event, place code similiar to this. This should point you in the right direction.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. If Not IsNull(Me.OpenArgs) Then
  3.   MsgBox "Form " & Me.OpenArgs & " opened this Report"
  4. End If
  5. End Sub
Jan 11 '07 #2

Expert 100+
P: 218
Hi, ADezii


Thx for your response.

Unfortunately, the OpenArgs property is already in use for other purposes ;-(

Ho hum

Steve
Jan 11 '07 #3

ADezii
Expert 5K+
P: 8,638
Hi, ADezii


Thx for your response.

Unfortunately, the OpenArgs property is already in use for other purposes ;-(

Ho hum

Steve
How about assigning a Public Variable representing the Form's Name when it is opened. It can then be read anywhere within the Project?
Jan 11 '07 #4

NeoPa
Expert Mod 15k+
P: 31,494
I don't think there is a prescribed way to do this I'm afraid Cyber.
ADezii's idea is probably the best you'll get.
Jan 12 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.