PC Review


Reply
Thread Tools Rate Thread

How to access global variable EXPLICITLY

 
 
vikram.singh@hp.com
Guest
Posts: n/a
 
      24th May 2007
Hi,

i have declared one global varibale named VAR1 in form module and
another defined in sub proecdure with the same name (VAR1) in the same
form module . if i use VAR1 then local variable will be
accessed .......but if i wanna use the global variable explicitely in
the same procedure then how i we do that.........

Please let me know as i am new to VBA.
Thanks in advance.

Vikram

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      24th May 2007
I don't believe you can. Change the name of one (or both) of the variables.

That's one of the reason why people use naming conventions such as prefixing
global variables with g, module-level variables with m and no prefix for
local variables.

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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> i have declared one global varibale named VAR1 in form module and
> another defined in sub proecdure with the same name (VAR1) in the same
> form module . if i use VAR1 then local variable will be
> accessed .......but if i wanna use the global variable explicitely in
> the same procedure then how i we do that.........
>
> Please let me know as i am new to VBA.
> Thanks in advance.
>
> Vikram
>



 
Reply With Quote
 
Bill Mosca, MS Access MVP
Guest
Posts: n/a
 
      24th May 2007
You have to decide on a naming convention so that global variables are not
confused with those scoped to only one sub or function.Adopting a naming
convention will make coding much easier for you.

Also, I suggest using names more descriptive than VAR1. Names like
gvarLastName indicates a global variant variable for Last Names.
gstrLastName indicats a string variable.

If the "global" variable is really scoped to only a form o rreport, I use p
instead of g. The p stands for private indicating it is scoped to just the
object in which it is declared.

--
Bill Mosca, MS Access MVP
http://tech.groups.yahoo.com/group/M..._Professionals


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> i have declared one global varibale named VAR1 in form module and
> another defined in sub proecdure with the same name (VAR1) in the same
> form module . if i use VAR1 then local variable will be
> accessed .......but if i wanna use the global variable explicitely in
> the same procedure then how i we do that.........
>
> Please let me know as i am new to VBA.
> Thanks in advance.
>
> Vikram
>



 
Reply With Quote
 
Bill Mosca, MS Access MVP
Guest
Posts: n/a
 
      24th May 2007
Sorry, Doug...I didn't refresh my list before responding.

--
Bill Mosca, MS Access MVP
http://tech.groups.yahoo.com/group/M..._Professionals


"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:%(E-Mail Removed)...
>I don't believe you can. Change the name of one (or both) of the variables.
>
> That's one of the reason why people use naming conventions such as
> prefixing global variables with g, module-level variables with m and no
> prefix for local variables.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>> i have declared one global varibale named VAR1 in form module and
>> another defined in sub proecdure with the same name (VAR1) in the same
>> form module . if i use VAR1 then local variable will be
>> accessed .......but if i wanna use the global variable explicitely in
>> the same procedure then how i we do that.........
>>
>> Please let me know as i am new to VBA.
>> Thanks in advance.
>>
>> Vikram
>>

>
>



 
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
How to access global variable EXPLICITLY vikram.singh@hp.com Microsoft Access VBA Modules 2 28th May 2007 12:18 AM
How to access global variable EXPLICITLY vikram.singh@hp.com Microsoft Access Macros 3 25th May 2007 11:45 AM
Explicitly declare the variable =?Utf-8?B?RGFuIEBCQ0JT?= Microsoft Access Queries 5 31st Mar 2006 07:26 PM
Same Global Variable Name/ 2 Access Apps? =?Utf-8?B?UGhpbGw=?= Microsoft Access VBA Modules 3 5th Dec 2005 11:17 PM
Global variable in DLL and access from C# gilad@arbingersysBADSPAMBOT.com Microsoft C# .NET 0 21st Jan 2005 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 PM.