How to make a mask in MS Access that works for 10 or 11 digit phones?

Asked

Viewed 2,451 times

2

I would like to know how to make a mask that works for phones of both 10 and 11 digits in Microsoft Access. Which would be:

(99) 1234-1234

(99) 12345-1234

I only know how to use the standard masks, and the ones I tried to do the "-" comes out in the wrong place for 10 digits (Ex.: (99) 12345-123).

Thank you in advance!

  • could post your attempts ( "-" in the wrong place )?

3 answers

2

Put the following script in the aoSair command of the text box focus

If isnull(Txttelefone) or TxtTelefone="" Then exit sub

Select case len(TxtTelefone)
Case 10 
    TxtTelefone=Format("00 0000-0000")
case 11
    TxtTelefone=Format("00 00000-0000")
case else
    msgbox "Preenchimento incorrecto."
docmd.cancelevent
end select

I believe it will work.

0

If isnull(Txttelefone) or Txttelefone="" Then Exit sub

Select case Len(Txttelefone)

Case 10

TxtTelefone=Format(TxtTelefone,"00 0000-0000")

case 11

TxtTelefone=Format(TxtTelefone,"00 00000-0000")

case Else

msgbox "Preenchimento incorrecto."

docmd.cancelevent

end select

So it’ll work out for sure

-1

Simple!

In the properties of the fields, both of cell phone hot fixed, in the column Data types select Short text and enter in the input mask field the following formats:

(99)9999-9999 for landline telephone (99) 99999-9999 for mobile.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.