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

how and where do i declare a global variable?

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
US
How and where do i declare a global variable?
 
You create module _Global
And here you write under

Option Compare Database
Option Explicit

Public Const RL2ID = "TIA"
Public ReportStartDate As Variant (if you need datatype)
Public Const ContractStartDate = #7/1/2002#
Public Const TemplateFileName As String = "ExcelFileName - YYYYMMDD.xls"

Ask if you need to know more
I have a lot to share on this subject

TIA
 
Or even better - tell what you are trying to do
 
Thanks for the fast response.
I'm not sure how to create 'module_global'
I need a global variable as it is easier than having to pass the var several times.
TIA
 
OK,
open up Access and click on Tab "Module"
then button "New" and Save it as _Global.
Open Up and you'll see

Option Compare Database
Option Explicit

Public YourVariableName As String (or whatever you need to be)

Then next step

Function GetYourVariableName()
GetYourVariableName = "HappyNewYear"
End Function

After this whenever you need "HappyNewYear" value - you can use YourVariableName or GetYourVariableName

Again, if you were more specific - I could help better

TIA :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top