
Originally Posted by
June7
Not understanding how the code could could print the 'wrong' form. If the print command is to print the open object, how is it printing the wrong one?
I don't fully understand how that happens either but I do know what triggers it.
Here's the code that the Print icon on the custom toolbar calls:
Code:
Function PrintMe()
On Error Resume Next
DoCmd.RunCommand acCmdPrint
End Function
If I add a couple of lines of diagnostic code to get the current object I get the correct answer. the DoCmd method though prints the wrong form!
This only happens if the OnCurrent event of a subform does a refresh. Now here's the thing. A subform does not support the OnCurrent event HOWEVER there's a trap, one can be added by creating a form and then using it as a subform.
Events available for a form that is going to be used as a subform:

Events available when the same form is used as a Subform:

I make the print button on the QuickAccessToolbar (I have customized the ribbon and QAT) available when the printable forms are opened instead of using a custom command button.
Remarkably that gets around the problem of the wrong form being printed, go figure.
Seems I have encountered other users that tried to requery subform combobox based on parameter of value on main form and encountered the issue you faced. The subform actually loads before the main form. Try code in main form Current event to requery the subform combobox. Or the subform GotFocus event. Or the combobox GotFocus event.
Beyond this, think I would have to analyse code/db do be more helpful.
Already tried adding code in the main form to Requery the Subform, it does nothing.
Also tried the subform and Combobox GotFocus (and other) events, well actually it seems SubForms cannot have a GotFocus event.
There is several ways around this including making a modal popup form that handles edits of the subform data. Not terribly elegant and I'd actually done that on another variant of the same database and the customer wanted the same functionality in a the other variants but without using a modal popup. Sigh, trying to explain to users why certain things in Access just cannot be done