! Checking for value in Textbox !

W

Wembly

Hi,

I was wondering if there is a way to check for the value
of a textbox whilst the value is being keyed in? If this
can be done, which event of the textbox must the VBA code
reside in order to check for the value as it is being
keyed in.

I've tried keydon, keyup, keypress, onfocus, beforeupdate,
all to no avail.

It appears that the value is only available once the focus
has moved from the textbox, which is not what I want,
since I want to be able to have the ability to do the
following.

If the textbox has any value in it, it will trigger off an
action, and if the user decides to backspace all the way
until there is nothing in the textbox, it will also
trigger off a different action.

Can this be done?

Thanks.
 
V

Van T. Dinh

If the TextBox has the focus, you can use the Text Property of the TextBox
to see the text currently being entered. Whether the Text is the same as
the Value depends on other factors, for example, if the TextBox is bound to
a date field and the Text is just "1", the Value doesn't make sense, does
it?
 
J

John Spencer (MVP)

If you want what is being entered into the textbox, then you need to check the
text property vice the Value property.

ME!SomeControl.Text returns what is currently being entered into the control,
while Me!SomeControl or Me!SomeControl.Value returns what has been entered into
a control (the value gets updated when the control loses focus).
 
M

Marshall Barton

Wembly said:
I was wondering if there is a way to check for the value
of a textbox whilst the value is being keyed in? If this
can be done, which event of the textbox must the VBA code
reside in order to check for the value as it is being
keyed in.

I've tried keydon, keyup, keypress, onfocus, beforeupdate,
all to no avail.

It appears that the value is only available once the focus
has moved from the textbox, which is not what I want,
since I want to be able to have the ability to do the
following.

If the textbox has any value in it, it will trigger off an
action, and if the user decides to backspace all the way
until there is nothing in the textbox, it will also
trigger off a different action.

A text box does not update its Value property until the user
does something to indicate that they've finished entering
the data (AfterUpdate event).

If you want to monitor what has been typed at each
character, then use the Change event procedure and look at
the text box's Text property.
 

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