473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Speeding up my code

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?

Many thanks,

Mark
Jul 8 '06 #1
3 1417
Bri
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

Jul 8 '06 #2
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

Jul 10 '06 #3
Bri
Once the variable is declared Public (use Public vs Global as they are
the same thing, but Public is more consistant with other versions) it is
initialized to 0 for numbers, empty string for text, Nothing for object,
etc. You can assign a real value to it at any time. Doing them all in
one place makes it easier to track them down later.

--
Bri

Mark Reed wrote:
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
Jul 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Snyke | last post by:
Hi. I have a command line script which works really fine, the only problem is that it take *really* long for the first output to be printed on screen. Since I also get some HTTP headers I'm...
12
by: dvumani | last post by:
I have C code which computes the row sums of a matrix, divide each element of each row with the row sum and then compute the column sum of the resulting matrix. Is there a way I can speed up the...
9
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields...
10
by: Timothy Graves | last post by:
I have a quick (pun intended) question for the guru's out there. I have a piece of code where I am validating the input of chancters into a cell in a datagrid. I am using the keypressed event to...
2
by: Robert Wilkens | last post by:
Ok... This may be the wrong forum, but it's the first place I'm trying. I'm new to C# and just implemented the 3-tier Distributed application from Chapter 1 (the first walkthrough) in the...
2
by: OHM | last post by:
I was wondering about this topic and although I accept that different situations call for different solutions, but wondered are there any other solutions and whether has anyone carried out a...
5
by: jcrouse | last post by:
I have a program that is an external viewer. It is launched with a hotkey from within another application. The program has 30 labels that can be displayed. Since the labels may not always be...
5
by: RobinAG | last post by:
Hello, I just split my database into front and back end. My front end users are experiencing really slow opening of forms. I've searched online for help speeding up forms, but I'm not sure what...
10
by: ags5406 | last post by:
I've created an application that downloads data daily from a secure web site and stores that data in an Access database. Then there are different options for allowing the user to do keyword and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.