Is there anyway to determine the form name that the report was called from? I would like to write some VBA code in report to determine where is the report was called from. I have Access 2003.
+1
A:
This is not possible unless you set it up yourself. You could write to a variable or, if the form remains open, store the information on the form.
Remou
2009-08-12 12:55:17
Umm, if he doesn't know what form is opening the report how can he store the form name in the report?
Tony Toews
2009-08-12 19:05:06
Sorry, but I do not get your point, I said store the information on the form if the form remain open, the forms can be checked from the report, or the form and report name are written to a variable, yesno?
Remou
2009-08-12 19:36:55
+3
A:
You can open a report like this:
DoCmd.OpenReport "reportFoo", acPreview, , , , Me.Name
and something like this in the report:
Private Sub Report_Open(Cancel As Integer)
If "" <> Me.OpenArgs Then
MsgBox Me.OpenArgs ' display caller form's name
End If
End Sub
Nick D
2009-08-12 13:04:57
The OpenArgs parameter did not exist in Access before 2002, I think (not sure if it was in 2002, either -- it might have been introduced in 2003).
David-W-Fenton
2009-08-12 19:17:11
+1
A:
One way is to have a report_caller class that always opens any reports. It needs a method called "openReport" that takes in the name of the form doing the calling and the name of the report being opened. Then it can have a public method to allow the report to get the name of the form that was opened.
sql_mommy
2009-08-19 02:51:31