Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Accessing text properties


Message #1 by martin.scullion@u... on Tue, 28 Jan 2003 11:41:16
I suspect this is a common error and has been reported before but I can't 
seem to find it anyway here goes

In VB I can access the Text property of a text box/Combo box/list box etc 
etc very easily like so :- txtname.text = "Fred".

However try the same thing in access VBA and it generates a weird error 
saying you can't use this property and then promptly falls in a heap.

Can anyone tell me the way round this, I suspect I am going to have to set 
a reference to the control and access it through the reference.

Your help would be much appreciated on this one. 
Message #2 by "John Ruff" <papparuff@a...> on Tue, 28 Jan 2003 03:47:10 -0800
The equivelant to VB's txtName.text Access is txtName.Value="Fred".  Since
Access assumes that when you try to read the value of txtName, or establish
the value of txtName (txtName.Value), then you don't need to refer to the
property .Value of the field txtName.  So, instead of txtName.Value="Fred",
you only need to say txtName="Fred".  

I know of one exception to this rule and that is the ActiveX control
Date/Time Picker.  To refer to the value of the Date/Time Picker, you must
use axDateTimePicker.Value=Date().
 

John V. Ruff - The Eternal Optimist :-)
Always Looking For Contract Opportunities

www.noclassroom.com
Live software training
Right over the Internet

Home:  xxx.xxx.xxxx
Cell: 253.307/2947
9306 Farwest Dr SW
Lakewood, WA 98498

"Commit to the Lord whatever you do,
	and your plans will succeed." Proverbs 16:3



-----Original Message-----
From: martin.scullion@u...
[mailto:martin.scullion@u...] 
Sent: Tuesday, January 28, 2003 11:41 AM
To: Access
Subject: [access] Accessing text properties


I suspect this is a common error and has been reported before but I can't 
seem to find it anyway here goes

In VB I can access the Text property of a text box/Combo box/list box etc 
etc very easily like so :- txtname.text = "Fred".

However try the same thing in access VBA and it generates a weird error 
saying you can't use this property and then promptly falls in a heap.

Can anyone tell me the way round this, I suspect I am going to have to set 
a reference to the control and access it through the reference.

Your help would be much appreciated on this one. 


Message #3 by braxis@b... on Tue, 28 Jan 2003 11:52:06 +0000 (GMT)
Hi Martin

Here's the Word from the Access help files:

______________________________________________________________
Note   To set or return a control's Text property, the control must have the focus, or an error occurs. To move the focus to a
control, you can use the SetFocus method or GoToControl action.

Remarks

While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the
last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property
is set to this new value. The Text property setting is then unavailable until the control gets the focus again. If you use the Save
Record command on the Records menu to save the data in the control without moving the focus, the Text property and Value property
settings will be the same.
______________________________________________________________


So, unless you need to know what's in the textbox currently, in which case the user is editing the text and the text property will
work fine, use the value property instead.

Brian

>  from:    martin.scullion@u...
>  date:    Tue, 28 Jan 2003 11:41:16
>  to:      access@p...
>  subject: Re: [access] Accessing text properties
> 
> I suspect this is a common error and has been reported before but I can't 
> seem to find it anyway here goes
> 
> In VB I can access the Text property of a text box/Combo box/list box etc 
> etc very easily like so :- txtname.text = "Fred".
> 
> However try the same thing in access VBA and it generates a weird error 
> saying you can't use this property and then promptly falls in a heap.
> 
> Can anyone tell me the way round this, I suspect I am going to have to set 
> a reference to the control and access it through the reference.
> 
> Your help would be much appreciated on this one. 

Message #4 by "John Fejsa" <John.Fejsa@h...> on Wed, 29 Jan 2003 12:13:52 +1100
Try .Value or just textbox name.

for example, 

Me!MyTextbox.Value = "Test" 'Specify Value

Me!MyTextbox = "Test" 'It will default to Value if property not
specified, much easier.

Hope it's of some help.


____________________________________________________


John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10, WALLSEND NSW 2287
Phone: (02) 4924 6336 Fax: (02) 4924 6209
www.hcha.org.au
____________________________________________________


The doors we open and close each day decide the lives we live

____________________________________________________


CONFIDENTIALITY & PRIVILEGE NOTICE

>>> martin.scullion@u... 28/01/2003 22:41:16 >>>
I suspect this is a common error and has been reported before but I
can't 
seem to find it anyway here goes

In VB I can access the Text property of a text box/Combo box/list box
etc 
etc very easily like so :- txtname.text = "Fred".

However try the same thing in access VBA and it generates a weird error 
saying you can't use this property and then promptly falls in a heap.

Can anyone tell me the way round this, I suspect I am going to have to
set 
a reference to the control and access it through the reference.

Your help would be much appreciated on this one. 

This message is intended for the addressee named
and may contain confidential information.

If you are not the intended recipient, please
delete it and notify the sender.

Views expressed in this message are those of the
individual sender, and are not necessarily the
views of Hunter Health.


  Return to Index