Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling command button from another form

Status
Not open for further replies.

Nermal52

Programmer
Sep 18, 2001
3
CA
I have written a procedure that runs when a command button is clicked in the subform. I would like to call this procedure from another form so that instead of clicking the button in the subform, the user can click a button in the main form and execute the code (I eventually want to hide the subform).
I know that in VB you can call a command button by using FormName.cmdbutton_click. However, I can't seem to get this to work in VBA.
Can anyone help?
Thank you!
 
I tried to do that, but it didn't seem to work. I tried naming it Public Function AddAncestry() and then calling it in the main form as AddAncestry(). Can you see anything wrong with that?
 
If it doesn't return any value, don't use Function but use Sub instead. Second, when you call you sub, don't use the parenthesys.
HTH
Alcar
 
Perhaps your function has a Me! operator in it that would make it fail when called from another location. Either make it public or put it in a module; I prefer the latter because it's easier to find.

Uncle Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top