Re: Defining constant values: how to?

Tech-Archive recommends: Fix windows errors by optimizing your registry



"mark s." <markseymour.89@xxxxxxxxxxxxxxxxxx> wrote in message
news:Psj5h.17531$cz.285103@xxxxxxxxxxxxxxxxxxxxxxxxxx
on 11/11/2006 8:21 AM Douglas J. Steele wrote:
"mark s." <markseymour.89@xxxxxxxxxxxxxxxxxx> wrote in message
news:Dpa5h.17470$cz.282223@xxxxxxxxxxxxxxxxxxxxxxxxxx
on 11/9/2006 10:27 PM Larry Linson wrote:
In the General, Declarations section of a standard module (for
application-wide accessibility) use a statement such as:

Public Const AppName As String = "The Application Name"


Thanks :) So how do I refrence these in the form code to use it?

Right now the code is:

Me.Caption = AppName _
& " " & AppVersion

and it is not working.

What does "not working" mean? Are you getting an error? If so, what's the
error? Is the caption being set to something other than what you
expected? If so, are you sure that the constants are set correctly? Are
you sure you put the declarations into a standard module, as opposed to
the module associated with a form, or a class module?


Okay, It's working; I wasn't just looking at the caption. ^_^;

Now I want to use those set constants in form controls (like a label, text
box, listbox etc.). But I do not know how to output it in the standard
module (Not a class module, because I know that you can't use "Public
Const" from looking at the help file on it.)

In the form's Load event, you'd put code like:

Me.MyLabel.Caption = AppName
Me.MyTextBox = AppVersion

Not sure how you'd intend to use the constants in a list box, although I
guess you could have something like:

Me.MyListBox.RowSourceType = "Value List"
Me.MyListBox.RowSource = AppName & ";" & AppVersion

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)



.