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

How do you pass a variable to a function in vba

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
I have a function which is called from several different forms' sub-routines, but I don't know how to pass a table name variable for example from the form to this function in code.This would be nice to do as it would eliminate duplication of this code in all these forms.Anyone?
 
Create a public variable in its own Module. That might work. Then you would share that variable with all forms.

HTH

Mary :)
 
Hi;
I used the following and it worked:

I defined a variable ToggleVar as public and a sub (or function) as public in a separate module as follwoing:

Public ToggleVar As Integer

Public Sub FilterToggle(Formname As Form)

Then I called this sub from different forms by using the follwing statement:

FilterToggle Me

In this way I passed the current form to the public sub.

Hope it will work with you

Tarek
 
I set up my code like tarekm and modified it to fit program needs and it worked fine.Thanks alot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top