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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run code in another private sub 1

Status
Not open for further replies.

Jusenkyo

Programmer
Aug 16, 2002
295
GB
Hello all

I have a few pages of VBA code behind a button on a form, that I want to be able to run from another button on a different form.
I havent used Public classes or whatever, so im not sure how to reference the code from a different procedure.

Anyone?

Cheers
J
 
If you have something like;

Private Sub btnClose_Click()
'your code here...
End Sub


change it to;

Private Sub btnClose_Click()
abc
End Sub

private function abc()
'Your code here...
End Function
 
Can you reference the private function from another form then?
 
That will work if you are in the same form.

To make it available to other forms do the following.
private Sub btnClose_Click()
Form_frmMainmenu.abc
End Sub

Public function abc()
'Your code here...
End Function

replace frmMainMenu for the name if your form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top