This should be easy. I'm trying to declare several global variables that will be available to every form in my database. After searching the internet, and through trial and error, I am pretty sure that I need to declare the variables as Public in the General section of a Module. I created a new module called Global Settings, and put my declarations in there:
Public gCurrent_Marshal As String
Public gCurrent_Marshal_ID As String
Public Const gChapter_Name As String = "ULTRA National"
Public Const gChapter_ID As String = "00"
However, when I try to read these variables, or change them using my forms, my forms act as though they do not exist. I have several text controls on my forms that instead of showing the value, they show #Name?
I know some other resources have said to make sure you are not declaring a module level or procedure level variable with the same name, and I have confirmed that I have NO other Dim, Public, or Private commands referencing these variables.
I have a Main Menu form that should display the values of gCurrent_Marshal and gChapter_Name. I have a Choose User form that references a table that has a list of user names and user id's that I use a List Box, unbound, and then set the following code for when they double click on a user name in the list box:
Private Sub lstChooseUser_AfterUpdate(
)
gCurrent_Marshal = Me.lstChooseUser.Column(0)
gCurrent_Marshal_ID = Me.lstChooseUser.Column(1)
End Sub
The same form also has text boxes to report the values of gCurrent_Marshal and gCurrent_Marshal_ID.
None of these controls work unless I declare the variables inside the general section of the form itself... but then it erases the variables, and they won't work *outside* the form.
What am I doing wrong? Do I have to have the forms reference the module in some way? Force the module to load?
"Z"
Start Free Trial