Problem with Control Button on Subform

jukus

Registered User.
Local time
Yesterday, 22:37
Joined
Jan 9, 2008
Messages
52
I am having trouble with a control button on a subform. I have the button set when it is click to view a report based on the current Primary field [ID]. Here is the code I have placed in the on click event. Of course that is between the two bits of code provide when you enter the code builder.

DoCmd.OpenReport "rptInvoice", acViewPreview, , "[ID]= Forms!frmMKInvoice!ID"

If I go to the subform frmMKInvoice and click the button it pulls the report like I want it to.

If I click on it while in the main form I get a box that wants me to enter the value for Forms!frmMKInvoice!ID. if I click cancel it bring up an error telling me I have a runtime error.

Do I have to do this different to get it work from a subform while viewing in a main form?

Thanks for any help
 
It is

DoCmd.OpenReport "rptInvoice", acViewPreview, , "[ID]=" & Forms!frmMKInvoice!ID
 
When I use that code it gives me an error. Can not find form when clicking on control button from main form.

If opening just the subfrom, it still works correctly.
 
I think you're referencing the subform control incorrectly. Try something like:

"[ID]=" & forms!MyMainFormName.MySubFormName.form!MyIDTextBoxName

Replace the 'My' stuff with the real names...

???
 
Seems to work fine. Thank you for all of your help.
 
Cool - Glad you have it working.
 

Users who are viewing this thread

Back
Top Bottom