Per Brent Ritchie:
What I want to do is declare a global variable, and then any form that
has to display the logo refrences that variable. I think it would be ok, but
many of my teachers have told me not to ever use them. Do you think it's a
good idea to run by my boss or should I just shut up and do it the manual
way?
I'd wrap the global in a function and then call the function.
e.g.
-------------------------------------------------
Const gWhatEver = "xyz"
-------------------------------------------------
-------------------------------------------------
Public Function CommonReportHeader() As String
CommonReporHeader = gWhatEver
End Function
--------------------------------------------------
--------------------------------------------------
Report_Open()
Me.txtReportHeader = CommonReportHeader()
End Sub
--------------------------------------------------
At first this looks a little convoluted, but one advantage is that once you get
it all running, move on to other things, and get stronger with VB; you have the
option of going back and re-coding CommonReportHeader() so that, instead of
getting the value from a global constant, it gets it from a .INI file, some
parm table in the DB, or even a freestanding text file.
Another advantage is that if someday, for some reason, you want to pull that (or
some other) data into a query you can call the same function.
I kind of like the .INI file approach. Then, if/when you wind up with common
boilerplate in many reports across many applications, the text only resides in a
single place.
The downsides of a .INI file solution would be the extra documentation and
(depending on the environment) the prospect of people being able to make
uncontrolled/undocumented changes - whereas with the data residing in a global
in the app, somebody would have to make a new rev of the app in order to change
it.
Especially within the confines of MS Access, I wouldn't agree with "never" when
it comes to globals. What I would say is that I'd better have a *really* good
reason to use a global instead of passing arguments from routine-to-routine.
My take on this subject comes from "Code Complete" by Steve McConnell/Microsoft
Press. Personally, I'd recommend that book to anybody anywhere as soon as they
find out they will be writing code.
--
PeteCresswell