Do I need to declare data type for TempVars

latex88

Registered User.
Local time
Today, 15:20
Joined
Jul 10, 2003
Messages
198
I am about 2/3 done with my application, but during of it, I keep losing the global variable when I come across errors. After some research, it would appear that instead of declaring a global variable and use functions everywhere, I should have started the entire process using TempVars. I think at this point, I may go back and change all the codes. I guess the usage of TempVars is still relatively new, as I do not find that much information on it.

1. Does anyone know a very good site that explains everything about TempVars?
2. Would you agree that TempVars are much more user friendly than the approach I've been using?
3. Do I need to declare the variable type in advance when assigning a TempVar?
 
http://msdn.microsoft.com/en-us/library/office/gg264189.aspx
This will get you started on a very important subject.
The term is Scope
I can say "you younger kids" because most of you are.
Back in the day when we had an entire 8k of RAM (not a typo) we really had to understand Scoping of Variables.
It will improve your programming career if you learn the Immediate Window, the Watch Window, and (very important) the Call Stack.

Back in the day I was a MS certified trainer for VB, Access and Excel programming.
I wrote a custom 1 hour course to kick the advanced users off with just these three things. That one hour raised programming productivity concepts for the entire week. It is amazing how some programmers dance around these very powerful tools.

It is quitting time here. Maybe some other people can put in 2 cents worth about the management of Variables, scoping and memory management. If you search on VBA and Scope - you will find some tutorials.

Just because you younger kids' computer has 8 GB of RAM - doesn't mean that you can be liberal with creating variables.
See, I told you I can say that.
And yes.. you will want to re-write your code to keep variables scoped as local as possible.
 
I have never been a fan of TempVars at least in part because I don't use accd* files.

Secondly because they do hang about in memory unnecessarily (see post by Rx).

Thirdly because I write the variable into the SQL string in VBA for Execution rather than using a saved query if it needs to include variables. Another alternative is to pass the variable to the Parameters collection of the saved query.

Note that the variables are not lost due to errors but at the reset in the dialog following an error. It is generally possible to avoid the need to reset (thus preserving the state) by commenting out the line with the problem and pressing the run button (green arrow in toolbar) instead.
 

Users who are viewing this thread

Back
Top Bottom