BD
asked on
Defining new TempVars? Use ADD or DIM to establish TempVar?
Question about the better code to use for defining a new TempVar. Use:
Is one method preferred over the other? Advantages to either method?
- TempVars.Add "NewTempVarsName", (set tempvars value)
- Dim NewTempVarsName As TempVar ...then a few lines down... TempVars!NewTempVarsName = (set tempvars value)
Is one method preferred over the other? Advantages to either method?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Question to Pat:
First, thanks for the explanation on setting TempVars, good info.
Second, using your hidden "global values" form, I assume you have a main form that is displayed when the database opens. Do you use Form_Load to place your code for opening the hidden form and entering your initial values? Could you provide an example of your code to do this? Also, how are you hiding the form?
I am very weak with VBA and trying to learn. Thanks.
First, thanks for the explanation on setting TempVars, good info.
Second, using your hidden "global values" form, I assume you have a main form that is displayed when the database opens. Do you use Form_Load to place your code for opening the hidden form and entering your initial values? Could you provide an example of your code to do this? Also, how are you hiding the form?
I am very weak with VBA and trying to learn. Thanks.
Joe, I agree that TempVars are useful. My point was that I solved the problem years ago and TempVars don't add anything to my existing solution and I think my existing solution is sufficiently good that it is worth a mention. TempVars were implemented because of Webforms and Data Macros so if you are using them, TempVars is your only option.
BD, I usually make my "hidden" form the form that opens when the database opens. In the Current event, I set any defaults that need setting for the form's controls or TempVars if I've used them in this app. Then I hide the current form by setting its visible property to False and open the Menu/Switchboard. There is no logic involved. It is simply a list of TempVars definitions followed by set statements if they variables need initiation.
Here's a picture of a hidden form from one of my apps. As you can see, all the controls are unbound. This particular app has no code in this form except to hide itself and open the switchboard since no TempVars were used and nothing required an initial value.
BD, I usually make my "hidden" form the form that opens when the database opens. In the Current event, I set any defaults that need setting for the form's controls or TempVars if I've used them in this app. Then I hide the current form by setting its visible property to False and open the Menu/Switchboard. There is no logic involved. It is simply a list of TempVars definitions followed by set statements if they variables need initiation.
Here's a picture of a hidden form from one of my apps. As you can see, all the controls are unbound. This particular app has no code in this form except to hide itself and open the switchboard since no TempVars were used and nothing required an initial value.
@Pat ... my post was unrelated to what you posted per se ... I simply commented and added my input on TempVars.
Not sure why ... you needed to address me in your last post ?
Not sure why ... you needed to address me in your last post ?
Tempvars.Add strVarName, varValue
or
Tempvars!VarName = varValue
Either method works just fine.