>Which is better to store temporary values? Dim or an Unbound Textbox.
>Is one faster? Is one more stable? Can you have several Dims? How
>many Dims is too many? Any downsides to one or the other?
He who allows unhandled errors, is an Unstable Developer
> >Which is better to store temporary values? Dim or an Unbound Textbox.
> >Is one faster? Is one more stable? Can you have several Dims? How
[quoted text clipped - 7 lines]
> a procedure (or module) is unlimited. The number of
> controls on a form or report is limited to a total of 754.
Marshall Barton - 31 Aug 2006 23:38 GMT
Not always, especially during debugging when Break On All
Errors is set.

Signature
Marsh
MVP [MS Access]
>He who allows unhandled errors, is an Unstable Developer
>
[quoted text clipped - 9 lines]
>> a procedure (or module) is unlimited. The number of
>> controls on a form or report is limited to a total of 754.
>>Which is better to store temporary values? Dim or an Unbound Textbox.
>>Is one faster? Is one more stable? Can you have several Dims? How
[quoted text clipped - 7 lines]
> a procedure (or module) is unlimited. The number of
> controls on a form or report is limited to a total of 754.
So They both have their pluses. I like the Textbox for stability, but
wouldn't using Dim be faster and also use less resources in Access than
Unbound textboxes. Also won't a form load faster without Unbound
Textboxes. One other question. If I open a form, how can I pass values
along to the new form with Dim. or do the values stay in Dim until they
are overwritten or cleared? If so how do you clear Dim?
Thanks
DS
Klatuu - 31 Aug 2006 20:28 GMT
You get your stability by using good error handling procedures. You can learn
about that in VBA Help under On Error.
A Dim statement only establishes the name and type of the varialbe. It
presists as long as it is in scope. You assign a value to it in VBA. It
retains that value until it goes out of scope or you change the value. You
don't really "Clear" a varialbe. It will always have some value as long as
it is in Scope. The default value of a variable depends on it's type. If
you need different forms to share the same variable, it has to be declared
(Dimmed) as Public in a standard module. There are also other techniques for
passsing values between forms, but that is beyond the scope of this
discussion.
> >>Which is better to store temporary values? Dim or an Unbound Textbox.
> >>Is one faster? Is one more stable? Can you have several Dims? How
[quoted text clipped - 16 lines]
> Thanks
> DS
Marshall Barton - 31 Aug 2006 23:48 GMT
>>>Which is better to store temporary values? Dim or an Unbound Textbox.
>>>Is one faster? Is one more stable? Can you have several Dims? How
[quoted text clipped - 14 lines]
>along to the new form with Dim. or do the values stay in Dim until they
>are overwritten or cleared? If so how do you clear Dim?
VBA variables are naturally faster and use less resources,
but, in practice, you will probably never notice the
difference. As Klatuu said, scope is very important. There
should be no need to use a text box instead of a local
variable. The question only makes sense when comparing a
variable declared as Public vs a text box on either the
current form or an always open form.
You place values in either a variable or a form control by
using a VBA assignment statement.

Signature
Marsh
MVP [MS Access]