Opening a report from subform in control source

GraemeG

Registered User.
Local time
Today, 22:11
Joined
Jan 22, 2011
Messages
212
Hello

I am having trouble opening a report from a command within a subform.

I have a main form with a control source in which a navigation panel no the main form dictates what opens in the control source i.e. subforms.
This all works great but one action I require is within this control source is a subform with a command button to open a report. But it wont open. However it will open when I just view that subform as a form and not in the control source.

Any ideas much appreciated thanks.
 
Post the code you are currently using along with the name of the main form, name of the subform, name of the control on the main form which houses the subform and the name of any control bound to a field which you are using to limit the report by.
 
Code:
Private Sub cmdKitchenTotalForecast_Click()
    DoCmd.OpenReport "Rep_Kitchens_CostProfile", acViewReport, , , acWindowNormal
End Sub
I want the report to open in a new window and not the control source where the subform is currently located.
This code is just attached to a command button in the subform.
Thanks
 
Resolved. I needed to make the report a popup.
Thanks for your help anyhow.
 
That code you gave should work regardless of where it is being run from - either subform or standalone. The part that might not work is if you have the underlying query referring to the form in any way as criteria. If so, remove it and use the WhereCondition here in this code to filter it by. That is why I asked about the names of the form, subform, subform control and any fields that it should be limited by.
 

Users who are viewing this thread

Back
Top Bottom