PC Review


Reply
Thread Tools Rate Thread

Defining a variable

 
 
=?Utf-8?B?QmlnZ2xlcw==?=
Guest
Posts: n/a
 
      2nd May 2006
I am having trouble with something I think is simple. Here is what I want to
do. I want to create a module that is simply a list of my commonly used
pieces of information, which I only currently have one, but nonetheless, I
want to use that in many queries, forms, reports. How should I set up the
module and then how do I reference it elsewhere. Right now, I simply have:

txtPLAN_YR = "2006"

in several places. I want to make that go away. Please help.

--
Ficticiously Yours, Biggles
 
Reply With Quote
 
 
 
 
John Nurick
Guest
Posts: n/a
 
      2nd May 2006
Hi Biggles,

Many of my databases have a module called vbGlobals which contains
(among other things) constant declarations for this sort of thing:

Public Const COMPANY_NAME = "Acme Firework Corp"

Another approach - if this is data that changes from time to time - is
to have a table for your settings:

tblSettings
SettingName - Text, primary key
SettingValue - Text

with records such as
"Plan Year", "2006"

You can then use DLookup() to retrieve the value wherever it's needed.



On Tue, 2 May 2006 13:03:02 -0700, Biggles
<(E-Mail Removed)> wrote:

>I am having trouble with something I think is simple. Here is what I want to
>do. I want to create a module that is simply a list of my commonly used
>pieces of information, which I only currently have one, but nonetheless, I
>want to use that in many queries, forms, reports. How should I set up the
>module and then how do I reference it elsewhere. Right now, I simply have:
>
>txtPLAN_YR = "2006"
>
>in several places. I want to make that go away. Please help.


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

 
Reply With Quote
 
=?Utf-8?B?QmlnZ2xlcw==?=
Guest
Posts: n/a
 
      2nd May 2006
Of course, my first reply is "Wow, you got to work on Acme Firework?" Sorry,
had to be said.

I would like to use that public const method, but how do I reference in
other modules? Is it something like

VBGLOBALS.COMPANY_NAME

?
--
Ficticiously Yours, Biggles


"John Nurick" wrote:

> Hi Biggles,
>
> Many of my databases have a module called vbGlobals which contains
> (among other things) constant declarations for this sort of thing:
>
> Public Const COMPANY_NAME = "Acme Firework Corp"
>
> Another approach - if this is data that changes from time to time - is
> to have a table for your settings:
>
> tblSettings
> SettingName - Text, primary key
> SettingValue - Text
>
> with records such as
> "Plan Year", "2006"
>
> You can then use DLookup() to retrieve the value wherever it's needed.
>
>
>
> On Tue, 2 May 2006 13:03:02 -0700, Biggles
> <(E-Mail Removed)> wrote:
>
> >I am having trouble with something I think is simple. Here is what I want to
> >do. I want to create a module that is simply a list of my commonly used
> >pieces of information, which I only currently have one, but nonetheless, I
> >want to use that in many queries, forms, reports. How should I set up the
> >module and then how do I reference it elsewhere. Right now, I simply have:
> >
> >txtPLAN_YR = "2006"
> >
> >in several places. I want to make that go away. Please help.

>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>
>

 
Reply With Quote
 
John Nurick
Guest
Posts: n/a
 
      3rd May 2006
As long as it's declared in an ordinary module (as against a form or
class module), just use COMPANY_NAME.

The capital letters aren't compulsory: I like to use them to make it
clear that this is a constant; I'd use CompanyName or strCompanyName for
a variable.

On Tue, 2 May 2006 14:41:21 -0700, Biggles
<(E-Mail Removed)> wrote:

>Of course, my first reply is "Wow, you got to work on Acme Firework?" Sorry,
>had to be said.
>
>I would like to use that public const method, but how do I reference in
>other modules? Is it something like
>
>VBGLOBALS.COMPANY_NAME
>
>?


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      3rd May 2006
John Nurick <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> The capital letters aren't compulsory: I like to use them to make it
> clear that this is a constant; I'd use CompanyName or strCompanyName for
> a variable.


Of course, strict Hungarian would make this gc_strCompanyName


Tim F

 
Reply With Quote
 
John Nurick
Guest
Posts: n/a
 
      3rd May 2006
Strict Hungarians are best left on cards in phone boxes, IMO.

On Wed, 03 May 2006 10:28:42 -0700, Tim Ferguson
<(E-Mail Removed)> wrote:

>John Nurick <(E-Mail Removed)> wrote in
>news:(E-Mail Removed):
>
>> The capital letters aren't compulsory: I like to use them to make it
>> clear that this is a constant; I'd use CompanyName or strCompanyName for
>> a variable.

>
>Of course, strict Hungarian would make this gc_strCompanyName
>
>
>Tim F
>


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      4th May 2006
John Nurick <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Strict Hungarians are best left on cards in phone boxes, IMO.
>
>


<vbg>


Tim F

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining a Variable =?Utf-8?B?UGhpbCBI?= Microsoft Excel Programming 3 22nd May 2006 12:04 PM
Defining a variable within a sub... aking1987 Microsoft Excel Programming 1 11th Nov 2004 01:12 PM
Defining a variable within a sub... aking1987 Microsoft Excel Programming 1 11th Nov 2004 12:32 PM
Help with defining variable Annon Microsoft Access Form Coding 1 24th Jul 2004 12:00 AM
Defining a Variable Stephen Microsoft Excel Programming 1 8th Sep 2003 11:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:05 PM.