@subedimite
There are various options open to you Global variables that are not constant is not one of them because they lose their scope once the database is closed or if you encounter an untrapped error during program flow.
The Easiest technique here, is this to create a one row table and call it UsystblConfigLocal (table names prefixed with 'Usys' automatically inherit the hidden atribute) that you can use to populate with all sorts of information and simply look your specific item up using the
DLookup function at an appropriate point in your program ie: shutdown, when database first opens and so on.
Then there are more advanced methods ie database 'properties' that you can consider where you might create a property and append it to the properties collection at runtime.
Another simple little option you might want to consider is creating an
'external' file that sits in the same folder as your database something that the database can refer to on open or on close or at whatever other point in time you wish. This type of external file creation technique, is often used as a yardstick to measure against, if you understand me ie: if the file exists on the hard drive, do this, that or the other so to speak.
The following two separate functions will create and read the contents from an external file and return the value of that content to your calling function. Like I say.....there are many ways to do this... this is but one technique.
The PutFilePath function creates the dat file in the same folder as your database and relies on a full filepath and filename being passed to it (which of course is what you would be doing with the File dialog functionality when you 'click the button' so to speak.
The GetFileContents Function simply reads this small file (which gets replaced incidentally) each time you create and returns the content value to the calling procedure
- Function PutFilePath(FilePath As String)
-
datpath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
-
Open datpath & "filepath.dat" For Output As #1
-
Print #1, FilePath & ",";
-
Close #1
-
End Function
-
Function GetFileContents() As String
-
Dim f As Integer
-
datpath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
-
datpath = datpath & "filepath.dat"
-
If Dir(datpath) <> "" Then
-
f = FreeFile
-
Open datpath For Binary Access Read As #f
-
mycontents = Input(LOF(f), f)
-
Close #f
-
End If
-
End Function
Nothing I have said is intended to show you the
best way, as that is always a subjective test, it is merely intended as a guider to certain options available to you. Ultimately you decide what best suits your purpose :)
Regards