-----Original Message-----
Yes, is possible to define Global Constants.
Public Const constname [As type] = expression
in a module. However, this means that you need to know the variables and
their values in advance: you can't do this dynamically.
If you need to be able to do it dynamically, you might consider a public
collection.
Global MyData As Collection
Sub SetValue(cmName As String, cmValue As String)
MyData.Add item:=cmValue, Key:=cmName
End Sub
Function GetValue(cmName) As String
GetValue = MyData.item(cmName)
End Function
Sub Example1()
Set MyData = New Collection
SetValue "FirstName", "Barry"
SetValue "LastName", "Elson"
End Sub
Sub Example2()
Debug.Print "FirstName = " & GetValue("FirstName")
Debug.Print "LastName = " & GetValue("LastName")
End Sub
If you call Example1, then Example 2 in the Immediate window, you'll get the
following
Call Example1
Call Example2
FirstName = Barry
LastName = Elson
Of course, we could probably give you better advice if we knew what you were
trying to do...
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I have looked at something like this, but would like the
Access application to be stand alone. I am just curious
if I can delclare these (cmName and cmValue) as a Global
Constant so that when they are called from other sub
routines in the application as optional arguments that
they would be available and recognized. I'm sorry if I
can't be more clear as I am a little confused myself as
to how to implement and/or completely understand the
concept. Thanks everyones help and comments
Barry instance
of Excel, and then
objExcel.Application.Workbooks.Open "C:\MyFolder\MySheet.x
ls" CurrentProject.AllMacros
cmName = cmValue is arguments
in
.