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

2

I would like to know how to make a mask that works for both 10- and 11-digit phones in Microsoft Access. Who would stay:

(99) 1234-1234

(99) 12345-1234

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

Thank you in advance!

    
asked by anonymous 16.06.2014 / 02:21

2 answers

2

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

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.

    
22.07.2014 / 21:52
0

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

Select case len (TxtTelephone)

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

This will work for sure

    
18.07.2017 / 02:26