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 / Modules / DAO / VBA / March 2007

Tip: Looking for answers? Try searching our database.

Best practice data-typing combo/text box contents

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
XP - 02 Mar 2007 13:36 GMT
Using Office 2003 and Windows XP;

If a text box control on a form contains a string, is it best practice to
use TEXT as in:    sData = Me.MyControl.Text

Then, if it contains a value to use VALUE as in:    iData = Me.MyControl.Value

Also, what is the best practice for determining if a textbox or a combo
contains a NULL. I've been using a construct like:

If Not IsNull(Me.MyControl.Value) Then iData = Me.MyControl.Value Else iData
= 0

Then I check the contents of iData. Is this the best or accepted practice?

Is there some other better fool proof way to get the contents and absolutely
deal with it without generating an error in the process and identify Null's,
or any other entry type, etc?

Please post a generic function if you have one. Thanks for your input and/or
discussion/advice on this.
Douglas J. Steele - 02 Mar 2007 14:12 GMT
AFAIK, there is no difference between what's returned for the Text or Value
properties. (plus, to refer to the Text property, the control must have
focus). Value is actually the default property, so it's not really necessary
to include it.

Rather than the If construct you're using, you could use the Nz function,
which is designed specifically for that requirement.

Try something like:

sData = Nz(Me.MyControl.Value, "")  or sData = Nz(Me.MyControl, "")

for string values, or

iData = Nz(Me.MyControl.Value, 0) or iData = Nz(Me.MyControl, 0)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Using Office 2003 and Windows XP;
>
[quoted text clipped - 22 lines]
> and/or
> discussion/advice on this.
XP - 02 Mar 2007 15:08 GMT
Thanks much Douglas; I will use NZ from now on; much better than my method.

How about if a control is either hidden or locked?

Can you suggest any shortcuts on returning data from controls in either of
those states? Controls must receive focus to unhide/unlock before data can be
retrieved from them, right?

> AFAIK, there is no difference between what's returned for the Text or Value
> properties. (plus, to refer to the Text property, the control must have
[quoted text clipped - 38 lines]
> > and/or
> > discussion/advice on this.
Douglas J. Steele - 02 Mar 2007 16:31 GMT
Nope. No difference referring to them if hidden or locked.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Thanks much Douglas; I will use NZ from now on; much better than my
> method.
[quoted text clipped - 52 lines]
>> > and/or
>> > discussion/advice on this.
 
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



©2008 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.