Cheers very much for the info Bri. After a little more research (Which I
should have done first), combined with your post, I came up with the
following which is called when the splash form is opened:
Option Compare Database
Option Explicit
Global NETWORK_DRIVE As String
Global LOG_DIRECTORY As String
Global LOG_FILE_EXTENSION As String
Global ARCHIVE_DIRECTORY As String
Global CUSTOM_INI_LOCATION As String
Global XP_USERNAME As String
Global XP_COMPUTERNAME As String
Public Sub Init_Globals()
NETWORK_DRIVE = KEY_Value("Keys", "network_drive")
LOG_DIRECTORY = KEY_Value("keys", "Log_directory")
LOG_FILE_EXTENSION = KEY_Value("keys", "log_file_extension")
ARCHIVE_DIRECTORY = KEY_Value("keys", "archive")
CUSTOM_INI_LOCATION = KEY_Value("keys", "custom_ini")
XP_USERNAME = fOSUserName
XP_COMPUTERNAME = Environ("Computername")
End Sub
My question is that there are some variables that I would like to set in the
same manner but I do not have the information available when the database is
first opened. Can I save setting the GLOBAL values until later and just set
them once the needed info is available?
If this is the case, is it just a matter of saying 'THIS_GLOBAL =
WHATEVER_IS_NOW_AVAILABLE' once I can reference the needed information?
TIA,
Mark
"Bri" <no*@here.comwrote in message
news:9TTrg.132087$iF6.94032@pd7tw2no...
Mark Reed wrote:
>All,
I have built a database recently which resides on a network server
which is constantly being re-structured. This is something I have no
control over so have had to incorporate a means by which the backend
moving will not cause too much of a headache and anyone can fix.
I decided to use an INI file to store several variables which can and
often do change.
I've also added a logging procedure which writes events to a text file to
aid me with ironing bugs out. Every time an event occurs, the READ_INI
procedure is being called to find out paths and file names to write to
which seems a little inefficient to me.
I have a splash screen within the database and was thinking that I could
use the 'Splash Loading' time to set the variables within the ini so that
I do not have to keep reading the values within them.
I'm still in the early stage of learning VBA so have no idea on how to do
this. Could someone offer any advice on what to do?
Yes, reading in these values once at the start of the app is the way to
go. If you load them into a global variable then they will be accessable
from anywhere in the code. One downside to this is that if the code gets
'Ended' (ie untrapped error gives user the Debug or End option and they
hit End) then these values get dumped. Global variables are declared in a
Modual not in a forms code.
Air Code (in a Modual):
Option Compare Database
Option Explicit
Public stPath2BE as string
Function Whatever() as String
blah
blah
Stuff to read your INI file
End Function
Air Code (in your splash form):
Option Compare Database
Option Explicit
Private Sub On_Open(Cancel as Integer)
stPath2BE = Whatever()
End Sub
--
Bri