Text boxes not accepting .text changes

J

Jayyde

Not sure what's going on exactly, but I have a couple of forms that are
throwing an error something like "controls BeforeUpdate or ValidationRule
will not allow this macro or event's operation" any time I have code that
takes a string, whether containing something like a selection from a list
box or and empty string, and tries to assign it to the text box's .text. As
of now, I've looked at the form, the text boxes themselves, and the list
box--none of them have code or macros for either the BeforeUpdate or
ValidationRule. I'd love any help that you gurus can give me on this one
=).
 
S

Sandra Daigle

Are you trying to assign a value to the control? In Access, the 'text'
property is only valid when the control has the focus and it is used to
differientiate what the user has typed from what is saved in the control.
When the control looses focus, the 'text' property is no longer relevant
since a value is already saved in the control. The 'text' property on an
Access control is not the same as on a VB control. The 'Value' property
more closely matches the VB 'text' property. Since the Value property is the
default property of a control you don't have to specify it at all so the
following are the same:

me.text1=null
me.text1.Value=null
 
J

Jayyde

Great, yeah VBer here, and these little quirks keep hooking me up here =\.
But to answer your question, each time this happens I've .setfocus to the
text box right before I assign the .text. I'll try your .value thing
though. If I assign a .value does it change the text displayed and does it
fire off any change or update events if I use it? (not sure if the latter
would actually trip me up at all, but it doesn't hurt to know, right?)

Sandra Daigle said:
Are you trying to assign a value to the control? In Access, the 'text'
property is only valid when the control has the focus and it is used to
differientiate what the user has typed from what is saved in the control.
When the control looses focus, the 'text' property is no longer relevant
since a value is already saved in the control. The 'text' property on an
Access control is not the same as on a VB control. The 'Value' property
more closely matches the VB 'text' property. Since the Value property is
the default property of a control you don't have to specify it at all so
the following are the same:

me.text1=null
me.text1.Value=null

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Not sure what's going on exactly, but I have a couple of forms that
are throwing an error something like "controls BeforeUpdate or
ValidationRule will not allow this macro or event's operation" any
time I have code that takes a string, whether containing something
like a selection from a list box or and empty string, and tries to
assign it to the text box's .text. As of now, I've looked at the
form, the text boxes themselves, and the list box--none of them have
code or macros for either the BeforeUpdate or ValidationRule. I'd
love any help that you gurus can give me on this one =).
 
S

Sandra Daigle

Changing the value will change what is displayed. Change and Update events
for controls are not fired when the values are changed programmatically. I
don't think you should have any problems but let me know if you do. Be sure
to post your code!

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Great, yeah VBer here, and these little quirks keep hooking me up
here =\. But to answer your question, each time this happens I've
.setfocus to the text box right before I assign the .text. I'll try
your .value thing though. If I assign a .value does it change the
text displayed and does it fire off any change or update events if I
use it? (not sure if the latter would actually trip me up at all,
but it doesn't hurt to know, right?)
Sandra Daigle said:
Are you trying to assign a value to the control? In Access, the
'text' property is only valid when the control has the focus and it
is used to differientiate what the user has typed from what is saved
in the control. When the control looses focus, the 'text' property
is no longer relevant since a value is already saved in the control.
The 'text' property on an Access control is not the same as on a VB
control. The 'Value' property more closely matches the VB 'text'
property. Since the Value property is the default property of a
control you don't have to specify it at all so the following are the
same: me.text1=null
me.text1.Value=null

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Not sure what's going on exactly, but I have a couple of forms that
are throwing an error something like "controls BeforeUpdate or
ValidationRule will not allow this macro or event's operation" any
time I have code that takes a string, whether containing something
like a selection from a list box or and empty string, and tries to
assign it to the text box's .text. As of now, I've looked at the
form, the text boxes themselves, and the list box--none of them have
code or macros for either the BeforeUpdate or ValidationRule. I'd
love any help that you gurus can give me on this one =).
 
J

Jayyde

Worked like a charm Sandra, thanks! I'm just over here stupified by why,
after 20ish forms it NOW has a problem with .text in these new ones lol. As
long as it works though (which it does), that feeling'll pass by the time
I'm done writing this post ;).

Sandra Daigle said:
Changing the value will change what is displayed. Change and Update events
for controls are not fired when the values are changed programmatically. I
don't think you should have any problems but let me know if you do. Be
sure to post your code!

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Great, yeah VBer here, and these little quirks keep hooking me up
here =\. But to answer your question, each time this happens I've
.setfocus to the text box right before I assign the .text. I'll try
your .value thing though. If I assign a .value does it change the
text displayed and does it fire off any change or update events if I
use it? (not sure if the latter would actually trip me up at all,
but it doesn't hurt to know, right?)
Sandra Daigle said:
Are you trying to assign a value to the control? In Access, the
'text' property is only valid when the control has the focus and it
is used to differientiate what the user has typed from what is saved
in the control. When the control looses focus, the 'text' property
is no longer relevant since a value is already saved in the control.
The 'text' property on an Access control is not the same as on a VB
control. The 'Value' property more closely matches the VB 'text'
property. Since the Value property is the default property of a
control you don't have to specify it at all so the following are the
same: me.text1=null
me.text1.Value=null

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Jayyde wrote:
Not sure what's going on exactly, but I have a couple of forms that
are throwing an error something like "controls BeforeUpdate or
ValidationRule will not allow this macro or event's operation" any
time I have code that takes a string, whether containing something
like a selection from a list box or and empty string, and tries to
assign it to the text box's .text. As of now, I've looked at the
form, the text boxes themselves, and the list box--none of them have
code or macros for either the BeforeUpdate or ValidationRule. I'd
love any help that you gurus can give me on this one =).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top