printing reports from sub-form

Tim Johnson

New member
Local time
Today, 10:27
Joined
Feb 15, 2000
Messages
8
I have a Parent Form X that has a tab control on it. On one of the tabs in the tab control I have a Subform Y.

I want to be able to print a report for a specific record in Subform Y.

When I run Subform Y by itself (not as a Subform of Parent Form X) and click on the button to create a report for a specific record it works fine. I am using the following code in the OnClick Event of the Preview Report Button:

DoCmd.OpenReport "ReportName",acPreview, ,
"[UniqueFieldName]=Forms![subformName]![UniqueFieldName]"

When I run Subform Y (on the tab control) through Parent Form X and click on the Preview Report Button I am prompted for the UniqueFieldName even though it is present on Subform Y.

I have tried placing the Preview Report Button on the Tab that Subform Y is on as well with the same results.

Do I need to refer to the UniqueFieldName on Subform Y differently since I am trying to access that field through Parent Form X and a tab control?

Any help would be greatly appreciated.

Thanks in advance,

Tim Johnson
 
The Y subform is a X form control; to refer using code yuo have to specify that the control you need is in a subform :
"[UniqueFieldName]=Forms![subformName].Form![UniqueFieldName]"
Hope this helps you
Stefano
 
thanks S,

I figured it out

Tim Johnson
 

Users who are viewing this thread

Back
Top Bottom