Calling Sub Procedure In Other Form

V

Vensia

Dear all,

I have two form called frmA and frmB.
In frmA, I have a sub procedure called cboPeriod_AfterUpdate.
frmA and frmB is loaded and I want to called the sub procedure
cboPeriod_AfterUpdate from frmB.
How to write the code ?
Thanks for helping.
 
R

Rev

Hi Vensia :)

I'm currious... Why do you want to execute the code in a combo box on
another form? I just wonder because it seems that if you are not updating the
ComboBox why would you want to run the code triggered by the AfterUpdate
event of the combo if it is not being updated? If it is just because you want
to run the code that is there for it's functionality, you might consider
moving it out to a form level sub procedure. I think that if you want to
execute the code in the afterupdate event handler of another form, you are
going to have to code an intermediate procedure to communicate between the
code in your Form A and the code in your combo in Form B. The after update
"Event is a private affair, unique to the scope of the form. It will not be
acknowledged outside that scope, so far as I know, that's what Private Sub
means: that it is private in it's class without worry of anyone in the other
classes trying to bring about a classless society. I'm kidding, but the
analagy is illustrative. So then, Why do you want to do this? What is the end
result you want to achieve?

Let me know, I can probably help...
rev
 
S

Sam D

Change the sub cboPeriod_AfterUpdate to a Public sub procedure (replace
Private with Public). You can then call this sub from anywhere using the
statement:

Forms!FormA.cboPeriod_AfterUpdate

HTH

Sam
 
A

Andreas

Change the declaration of the procedure from
Private Sub cboPeriod_AfterUpdate
to
Public Sub cboPeriod_AfterUpdate

You can now call the procedure using
cbo_Period_AfterUpdate
(or
frmB.cbo_Period_AfterUpdate
I can't remember)

Regards,
Andreas
 
A

Andreas

Oops, I slipped - old question, ignore.

Change the declaration of the procedure from
Private Sub cboPeriod_AfterUpdate
to
Public Sub cboPeriod_AfterUpdate

You can now call the procedure using
cbo_Period_AfterUpdate
(or
frmB.cbo_Period_AfterUpdate
I can't remember)

Regards,
Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top