OK, that sounds good. Being that I have something that meets that
criteria, he path to the redundant database, I think that would
work. If for any reason I need to change the path during the day
would that be a problem? Would closing the application be a
problem? I mean this de-initializing? Is this a Class Module,
Can I refer to it on many different forms?
Public Function REDACT() As String
Static strPath as String
strPath = Nz(DLookup("BackPath","tblBackPath","BackID=1 AND
BackActive=-1"),"")
End Function
Your static variable hasn't accomplished anything here, as you are
re-initializing it any time you call the function. Second, you
aren't returning your strPath value. You want to do something like
this:
Public Function REDACT(Optional bolReInitialize As Boolean) _
As String
Static strPath as String
If Len(strPath) = 0 Or bolReInitialize Then
strPath = Nz(DLookup("BackPath","tblBackPath", _
"BackID=1 AND BackActive=-1"),"")
End If
REDACT = strPath
End Function
If you call it without the parameter, you get the looked up value
the first time, and the value stored in the static variable all
further times. If pass True as the parameter, then it will look up
the value again.
If the value in the table is going to change during an application
session, then you really don't want a static variable -- you want it
looked up every time.