How tell if I have typed characters into a textbox?

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

When the user initially clicks in a text box I want to position the cursor to
the left, however after typing in some characters I want it to position where
it is clicked. How can I do this? My Click event code is:
If Me!Control.value = Null Then
Me!Control.selstart=0
Me!Control.sellength=0
End if
But it does not work because it appears the value is not set until I exit
the control, so it is still Null after I have typed in characters.
 
While the text box still has focus, examine its Text property, e.g.:
Debug.Print Me!Control.Text

Access is different to purer VB here, because it's data centric. For
example, in a text box bound to a date field, while you are typing the Text
could be just:
3/
but that could never become the Value.
 
In addition to what Allen's told you, you cannot use = (nor any other
comparison operator) to check for Null. You must use the IsNull function:

If IsNull(Me!Control.value) = True Then
Me!Control.selstart=0
Me!Control.sellength=0
End if
 
Back
Top