Modules

  • Thread starter Thread starter Sash
  • Start date Start date
S

Sash

Hi everyone. I'd like to start by thanking everyone. I'm self-taught and
have learned a tremendous amount through these message boards. That being
said, you'll understand that I'm still quite fresh.

I want to define several items that I can define publicly and access from
any form in the database. Below is a very simple example of one thing I'd
like to define whereby I would be able to reference lgwhite anywhere in the
database for the result of RGB(255, 255, 255).

I'm assuming you'd place some kind of code in a Module. I know the
following is wrong, but it's the best way I can try to describe.

Public
Dim lgwhite as long
lgwhite = RGB(255, 255, 255)
End Sub
 
Sash said:
Hi everyone. I'd like to start by thanking everyone. I'm self-taught and
have learned a tremendous amount through these message boards. That being
said, you'll understand that I'm still quite fresh.

I want to define several items that I can define publicly and access from
any form in the database. Below is a very simple example of one thing I'd
like to define whereby I would be able to reference lgwhite anywhere in
the
database for the result of RGB(255, 255, 255).

I'm assuming you'd place some kind of code in a Module. I know the
following is wrong, but it's the best way I can try to describe.

Public
Dim lgwhite as long
lgwhite = RGB(255, 255, 255)
End Sub


Since that's a constant value, you don't actually need to evaluate the
function every time. Therefore, you could define it as a public constant in
a standard module. It would go in the Declarations section, so you might
see something like this:

'----- start of module code -----
Option Compare Database
Option Explicit

Public Const conWhite As Long = 16777215
'----- end of module code -----

Note that I said this would to be a *standard* module, not a form or report
module. If you have a number of such constants, you might possibly create a
module named "modConstants" just for the purpose. On the other hand, if you
have a module containing utility routines that you use a lot, the constants
could be declared there instead, without needing to create a new module for
them.
 
Back
Top