Variable visible to all forms?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on a rather complex database application with lots of involved,
user-friendly forms. In the first form my users see, they indicate what
"Section" they belong to. In many of the other forms they would use after
that, the data displayed depends upon that "Section", but, of course, I'd
rather not have the user enter this piece of information on every form they
go to.

Is there a way to store this data such that every form can access it
whenever it is needed?

Thanks, all.

-ndalton
 
Use a Static function. Put it in a standard module. A static function will
retain its value until changed or until the database is closed and is
available from anywhere in the application.

Static Function GetSectionName(Optional ByVal varNewSection As Variant) As
String
Dim varSection As Variant

If Not IsMissing(varNewSection) Then
varSection = varNewSection
End If
GetSectionName = varSection
End Function

So in the after update event of the form where the user enters their section,

GetSectionName(Me.txtSection)

Then when you need it

strSomeVarialbe = GetSectionName
 
Back
Top