Open form then run its code

songbird3

New member
Local time
Yesterday, 20:50
Joined
May 11, 2011
Messages
5
I *had* this VBA code working in Access 2007, overwrote it, and cannot recreate it. I have a switchboard with buttons, click, open a form, and then I need a subprocedure on it to operate. The code that worked only took 3 or 4 lines. My logic probably was open the form, make it the active form, ask its code to run with a supplied parameter. Any and all help is GREATLY appreciated.
 
Do you mean you need a procedure to run as soon as it opens? If so open the form in design view and (in 2003 i dont have 2007 sorry) there is a square in the top left. Right click it and under the event tab create the procedure On Open. If that helps...
 
Thanks, but I don't want this code to run "On Open" event but only run when it is opened with this button. Other times, I open the same form for a different purpose and do not need the procedure.
 
Thanks, but I don't want this code to run "On Open" event but only run when it is opened with this button. Other times, I open the same form for a different purpose and do not need the procedure.
Why not use the On Click event of the button then.
 
Rabbie, Of course I am using the "On Click" event of the button! This is what opens the form, adds data to a field, etc. My question was not "On what event do I write my VBA code?" I need to add to the existing code to call one subprocedure on the form that is opened.
 
Thank you for your help! I realized I had the procedure on the opened form created as Private instead of Public. Now it works just fine.
 

Users who are viewing this thread

Back
Top Bottom