By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,491 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,491 IT Pros & Developers. It's quick & easy.

variables in use

P: n/a
Hi access gurus,

Is there a way to see what variables are currently in
use/active/declared/...?

so that I can identify where my code my need some cleaning up???

TIA.

- Nicolaas
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You should find all global variables in a standard module and local variables in
form and report class modules. Start with the global variables by going to the
first variable, put XX in front of the name and go to Debug - Compile. You
should raise an error at each place in code that variable is used. Repeat for
each variable. It's a tedious manual way of doing it!

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:LF***************@news.xtra.co.nz...
Hi access gurus,

Is there a way to see what variables are currently in
use/active/declared/...?

so that I can identify where my code my need some cleaning up???

TIA.

- Nicolaas
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004

Nov 13 '05 #2

P: n/a
Sorry, that is not really what I meant. I wanted to see which ones where
still initialised at any given point. Not declared at such. I hope that
makes sense.

- Nicolaas
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004
Nov 13 '05 #3

P: n/a
Hi Nicolaas

For checking if the variables are declared I'll suggest you to use the
"option explicit". Just enter it (option explicit) at the top of your
module. Option explicit needs all variables to be declared. If you
like to have "option explicit" everytime you are creating a new module
just change the option "require variable declaration" in the
properties.

To see which variables are used/active you need the windows "watches".
Via the menu view you can get the watches-windows visible. There you
can add the variables you like to track. Be aware, that this only
works when the code is running, means you have to run it via "step
into" (F8) or you let the code break when the value of your variable
is changing.

You can also use the immediate window. But I would only use this if
you like to check the value of the variables. In the code you have to
write:

debug.print varname

In the immediate window the value will be showed. You can use all
Functions (e.g.: len(varname)) and calculate (e.g.: long1 + long2) or
just writing strings (e.g.: varname & " " & varname2)...

Example for your code:

Sub test()
Dim strTest as String, strTest2 as String, lngNumber as long

strTest = "Hello"
strTest2 = "Folks"
lngNumber = 1

Debug.Print strTest & " " & strTest2
Debug.Print lngNumber + lngNumber
Debug.Print len(strTest)

End Sub

In your immediate window you'll see after running the code:
Hello Folks
2
5

But as already wrote, I would use the watches and "option explicit" to
clean your code...

Cheers

Susanna


Is there a way to see what variables are currently in
use/active/declared/...?

so that I can identify where my code my need some cleaning up???

- Nicolaas

Nov 13 '05 #4

P: n/a
thank you Susanna

I knew about all that, but not about the watches. I would like to try that.
I will have a look at this now.

Thank you.
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004
Nov 13 '05 #5

P: n/a
Except for object variables, global variables (Public variables in standard
modules) do not have any separate "initialization" -- they are there, they
exist whenever the application is running. The only way to determine if they
have particular values is to write code to test the particular variable for
the value. Again, that would be a laborious manual process.

Variables in Form or Report modules, and variables declared inside
procedures have somewhat more restrictions, but still do not fit the model
you describe.

Larry Linson
Microsoft Access MVP
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:y1***************@news.xtra.co.nz...
Sorry, that is not really what I meant. I wanted to see which ones where
still initialised at any given point. Not declared at such. I hope that
makes sense.

- Nicolaas
---
Please immediately let us know (by phone or return email) if (a) this email contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.700 / Virus Database: 457 - Release Date: 06/06/2004

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.