Results 1 to 2 of 2
2004-07-16, 13:23 #1
- Join Date
- Jun 2002
- Nottingham, Nottinghamshire, United Kingdom
- Thanked 0 Times in 0 Posts
Passing information to a report (All)
I want to design a report that can be opened from several different forms using DoCmd.OpenReport. At present I have several virtually identical reports but could simplify these down to one if I was able to interrogate the calling forms through the Report's activate event.
If CallingForm = frmThis Then
Change the contents of certain text boxes
My problem is I can't work out how to reference the name of the calling form. Me.Name gives the name of the report not the form that called it, Me.Parent.Name gives an error. Can anyone help me with the syntax.
2004-07-16, 13:35 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: Passing information to a report (All)
In Access 2002 and up, reports have a new OpenArgs property that you can set in DoCmd.OpenReport; you can use this to pass the name of the calling form. OpenArgs is not available in Access 2000 and earlier, however.
You can define a global variable in a standard module:
Public gstrCallingForm As String
In the code that opens the report, set this variable to the name of the form:
gstrCallingForm = Me.Name
DoCmd.OpenReport "rptMyReport", acViewPreview
And in the code behind the report:
Select Case gstrCallingForm
' Reset variable for next time
gstrCallingForm = ""