Focus and before_update

J

Jess

I have a form where the before_update sub is run before changes are updated.
I need to analyze the text property content for a few textboxes on my form in
order to decide whether the data is correct or no -if not correct, me.undo is
called. I get an error because most of the textboxes do not have the focus.
The validation rule property cannot be used since before_update calls
different functions to analyze the data.

Can anybody point me to a workaround? I do not want to shuffle the focus
around in order to access the text property.

Thanks
 
J

Jack Leach

Well, if you're running the Form's Before_Update, you generally shouldn't
need to check Text values of a control... most likely the control has already
been updated and the .Value of the control will be the same as the .Text of
the control.

Have you considered validating the controls individually on the control's
BeforeUpdate rather than the form's? With this approach the control is
likely to already have the focus (and the Text and Value properties are much
more likely to differ...)

As far as not shuffling the focus around, I personally don't see much of a
reason to not do this. I do it in some forms, and generally things happen
fast enough so that the user doesn't even notice. DoCmd.Echo Off and On may
help if that's what you're worried about.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
S

Sky

Jack Leach said:
Have you considered validating the controls individually on the control's
BeforeUpdate rather than the form's? With this approach the control is
likely to already have the focus (and the Text and Value properties are
much
more likely to differ...)

I have generally not seen any difference between the .Text and .Value
property of a control in the BeforeUpdate event. I could be wrong; do you
have an example of this? (There is definitely a difference while the user is
typing, but not once the typing is finished and the control value is being
saved in BeforeUpdate.)

There is definitely a difference between the control .Value and a bound
field value, since the update has not yet occurred in the BeforeUpdate
event.

- Steve
 

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