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

Global Variable 1

Status
Not open for further replies.

Watermelon

Programmer
Apr 16, 2001
68
US
Hi,

This might be a stupid question but I'm just trying to create a globabl variable on one form that I can call from other forms. I'm kind of new to Access and I'm not sure how to do this.

Thanks for any help,
TM
 
Declare the variable in a module, then you can access it from any form. Mike Rohde
rohdem@marshallengines.com
 
Hi,

Thanks Rodhem. I tried that but somehow when I call the variable from another form it's coming up as an empty string. Do I have to assign the variable a value in the Module?
Thanks
 
No, you shouldn't have to assign a value to it in the module. Try putting 'public' in front of it:

Public variablename As String Mike Rohde
rohdem@marshallengines.com
 
One more thing, don't put it inside a sub or function. Declare it right beneath the 'Option Explicit' line. Mike Rohde
rohdem@marshallengines.com
 
Thanks,

Yeah, it does work now. I think I was missing the 'Public.'

Thanks again,
TM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top