Input Mask query

R

Raymond

Hi all,

I have a textbox for telephone and fax nos. for which i added the input mask
as telephone no. (999)-(999)-(9999) (the default no., that is...) The
requirement is that if a no., say, +86-23-4455 has to be added, the format
does not alllow it and writes the no. as +86-234-455. Also, it should not
become +86-023-4455 as this becomes a different telephone no...

How do I correct this problem...As far as i undrstnd, i'll go for a do while
loop on the mask and when the appropriate condition arises, i can put the
codes..but i am unable to do that..>>> Your help will be acknowledged....
 
S

strive4peace

Hi Raymond,

the InputMask,as I understand it, is applied when you enter or change
the data ...

that said, you can

1. remove the mask
2. enter data

how do you do this?

make an unbound textbox to enter a phone number with any symbols

on the AfterUpdate event, remove the mask from the phone textbox (make
sure it is defined in the form, not at the table level), place the data
in, save the record, then put the mask back


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
R

Raymond

Hey, i didn;t understand how we can accept the record from the user after
disabling the mask..what's the command??/

me.phonetextbox.inputmask=false
????????????????????????? What comes here???????????
me.phonetextbox.inputmask=true
 
S

strive4peace

Hi Raymond,

you would do something like this in the AfterUpdate event of the UNBOUND
textbox to create a phone number:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Error GoTo Proc_Err

Dim mPhone As String

If Len(Trim(nz(controlname_UnboundPhone,""))) = 0 Then
GoTo Proc_Exit
End If

Me.Phone.InputMask = ""

Me.Phone = controlname_UnboundPhone

' clear unbound phone control
Me.controlname_UnboundPhone = null

'save the record
me.dirty = false

Me.Phone.InputMask = "!\(999"") ""000\-0000;0;_"

Proc_Exit:
Me.Phone.SetFocus
Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " PhonePaste"
Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

WHERE
controlname_UnboundPhone is the control NAME of your unbound phone number
Phone is the control NAME of your phone number

theoretically this should work ...

~~~~~~~~~~~
for better understanding of the basics of Access, read this:

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

Warm Regards,
Crystal

remote programming and training



*
:) have an awesome day :)
*
 

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

Top