Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2006

Tip: Looking for answers? Try searching our database.

Dim VS UnTexbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DS - 31 Aug 2006 17:54 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
many Dims is too many?  Any downsides to one or the other?
Any info appreciated.
Thanks
DS
Klatuu - 31 Aug 2006 19:59 GMT
Unbound text boxes would be inapproprate for storing variables.  It would be
slower.
All variables should be Dimmed
It is important that you understand varialbe "Scoping", that is what the
visibility of a variable is.  Start by looking in VBA Help for the Dim
statment.

> 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?
> Any info appreciated.
> Thanks
> DS
Marshall Barton - 31 Aug 2006 20:01 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
>many Dims is too many?  Any downsides to one or the other?

VBA variables are defintely more efficient.  Because any
unhandled error reset your project (clears all variables),
an unbound text box is more stable.

For all practical purposes, the number of Dim statements in
a procedure (or module) is unlimited.  The number of
controls on a form or report is limited to a total of 754.

Signature

Marsh
MVP [MS Access]

Klatuu - 31 Aug 2006 20:10 GMT
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.
DS - 31 Aug 2006 20:15 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 - 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]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.