Cursor position with input mask

M

mscertified

I'm dealing with phone number input. I have a mask (000) 000-0000. Is there
any way to force the cursor to go to the leftmost position when the user
clicks in a blank control? I've tried everything I can think of and nothing
works without messing up the cursor position when the control is not blank. I
dont want the cursor position to adjust if there are any characters in the
control even if focus has not yet moved off the control. This means I cannot
use the control .Value property and the .Text property does not seem to give
me what I want either.
 
S

Stockwell43

Hi,

Try this in the Got Focus of your field:

Me!FieldName.SelStart = 0

I just tried it and it seemed to work for me.
 
M

mscertified

It works but also works when I *don't* want it to. Read my post fully to
understand the situation..
 
B

Beetle

Have you tried anything like this;

Private Sub ControlName_Click()

If IsNull(Me.ControlName) Then
Me.ControlName.SelStart = 0
End If

End Sub

Or if you need to trap for ZLS you could use

If nz(Me.ControlName, "") = "" Then
 

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

Similar Threads


Top