Full Version: run code on a subform
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
theWA
Hello all,

I can't seem to get the correct syntax to execute code that exists in the on_click event of a button on a subform.

I have mainform, mainformbutton, subform and subformbutton. Subform is a continuous form.
In the mainformbutton on_click event i do a few things and then want to call a button on the subform to do some repositioning on the subform.
Can I use the Call approach? If so I would appreciate assistance on how to write the code.

Thanks
ace
Your first hurdle is that a form's events are declared as Private by default.
You need to change the Private keyword to Public before you can call
the code form outside the form's code module.

Personally I would not put code in any event if I wanted to run it from
another module. I would create a separate public sub routine and call
that routine from the Click event and where ever else was necessary.
theWA
The code is in a public sub on the subform. I needed the syntax to call it from the main form.
ace
From the mainform code module:

Call Me.subform.Form.PublicSubName
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.