Input mask on textbox (1 Viewer)

Derek

Registered User.
Local time
Today, 14:12
Joined
May 4, 2010
Messages
234
Hi guys,

I want an input box on the textbox so it will accept only 10 digits. It shouldn't allow users to enter less than or more than 10 digits.

How can I achieve this using vba?

Thanks
 

Ranman256

Well-known member
Local time
Today, 17:12
Joined
Apr 9, 2015
Messages
4,339
not input mask,

validation rule: Len([txtBox])=10
validation text: Must be 10 chars
 

Derek

Registered User.
Local time
Today, 14:12
Joined
May 4, 2010
Messages
234
I have written the following code and it works fine but is there any way we can display 10 under scores ( like input mask so the users will know they need to enter 10 digits??)

Code:
Private Sub txtAccount1_Change()
Static abort As Boolean
    Static c
   If abort Then: abort = False: Exit Sub
    With txtAccount1
        c = c + 1
         abort = True
        .Text = Left(.Text, 10)
    End With
End Sub
 

Derek

Registered User.
Local time
Today, 14:12
Joined
May 4, 2010
Messages
234
Basically 10 underscores (_) should appear on the textbox and it shouldn't allow users to enter more than 10 digits.

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:12
Joined
Oct 29, 2018
Messages
21,454
Hi Derek. What’s wrong with using an Input Mask? What have you tried?
 

Derek

Registered User.
Local time
Today, 14:12
Joined
May 4, 2010
Messages
234
How can I use input mask to allow 10 digits in a textbox? I just tried the below code which won't let users enter more than 10 digits but I want to show 10 underscores (input mask)

Code:
Private Sub txtAccount1_Change()
Static abort As Boolean
    Static c
   If abort Then: abort = False: Exit Sub
    With txtAccount1
        c = c + 1
         abort = True
        .Text = Left(.Text, 10)
    End With
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:12
Joined
Oct 29, 2018
Messages
21,454
Right. You keep saying Input Mask, but you haven’t shown us what you tried in the Input Mask. For example, have you tried? 0000000000;;_

Sent from phone...
 

Derek

Registered User.
Local time
Today, 14:12
Joined
May 4, 2010
Messages
234
I'm using outlook VBA and can't see any input mask option in properties for the textbox :(
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:12
Joined
Oct 29, 2018
Messages
21,454
I'm using outlook VBA and can't see any input mask option in properties for the textbox :(
I see. I did not realize that since you posted your question in an Access forum. No wonder I couldn’t understand what the problem was. Unfortunately, I am not familiar with Outlook controls to be able to offer any further suggestions. Good luck.
 

Users who are viewing this thread

Top Bottom