Form Load / Open Question

commandolomo

Registered User.
Local time
Today, 08:45
Joined
Jun 11, 2004
Messages
73
Hey y'all

I have some code that runs upon 'FormLoad' of Form A, and I am currently writing some more vba that is to open Form A from a Command Button on Form B.

What I want is for the code that is on Form A, to be triggered upon the clicking of the Command button on Form B. I am using the 'DoCmd.OpenForm "FormA"', but this does not trigger the code that is placed on the FormLoad property of Form A. I cannot seem to find an alternative 'DoCmd.LoadForm "FormA"' command.

I have tried putting the Form A code on the Form_Open property, but when I try to open the form, I get an error stating "The OpenForm Action was cancelled."

Does anyone have any ideas of workarounds / what I am doing wrong?
 
Upon FormLoad on Form A, I have


[Forms]![Form A]![id] = [Forms]![Master Table]![id]


which pre-populates a value (id number) from the Master Form into a certain field in Form A, so that a record on sub form that relates to the Master Table record have the same id.

The code on Form B, to open Form A, that I have tried is

stLinkCriteria = "[id]=" & Me![id]
DoCmd.OpenForm "FormA", , , stLinkCriteria

but because the id number on Form A is only generated upon FormLoad, and this uses "OpenForm", the id number is not generated in the field in Form A.

Hope this clarifies somewhat!
 
The first question is to know which events are firing.

Use the debugger to put breakpoints at the first executable line of each of your form_open and form_load event routines. See what breakpoints are hit - and which are not.

If you open A directly (not from B) does your event code get run? (Or can you even tell?)
 

Users who are viewing this thread

Back
Top Bottom