Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Defining constant values: how to?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark s. - 10 Nov 2006 01:54 GMT
I'm making a Micorosoft Access 2000 DB.

What I want to do is to declare several constants (in VBA6) that I can
reuse in other code such as me.caption, instead of trying to use a table
 to store just that information.

The constants that I wanted are Application Name, Version, Creation
Date, and Creator, for starts.  I'm a newbie at (VB), although in the
past I used Access + VB6 but stopped for a couple of years.

I appreciate the help.

-Mark
Larry Linson - 10 Nov 2006 02:27 GMT
> I'm making a Micorosoft Access 2000 DB.
>
[quoted text clipped - 5 lines]
> Date, and Creator, for starts.  I'm a newbie at (VB), although in the
> past I used Access + VB6 but stopped for a couple of years.

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"

Note that I did not use "Application Name" as there can be no blanks in a
Variable name (there can be in a Field name, but I don't recommend it there,
either). In the module window, type in Const, place the cursor in that word,
and press F1 for Help on declaring Constants.

On the other hand, I've found a table just for "Info" of this kind to be a
useful development technique.  And, if that is kept in a separate MDB to
which the user is linked, it can be used to save/maintain personal
preferences.

Larry
mark s. - 11 Nov 2006 02:18 GMT
>  > I'm making a Micorosoft Access 2000 DB.
>  >
[quoted text clipped - 22 lines]
>
>  Larry

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.
Douglas J. Steele - 11 Nov 2006 12:21 GMT
>> In the General, Declarations section of a standard module (for
>> application-wide accessibility) use a statement such as:
[quoted text clipped - 9 lines]
>
> 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?

Signature

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

mark s. - 11 Nov 2006 12:35 GMT
>>> In the General, Declarations section of a standard module (for
>>> application-wide accessibility) use a statement such as:
[quoted text clipped - 15 lines]
> 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.)
Douglas J. Steele - 11 Nov 2006 15:42 GMT
>>>> In the General, Declarations section of a standard module (for
>>>> application-wide accessibility) use a statement such as:
[quoted text clipped - 22 lines]
> 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

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.