Solved Copying telephone numbes

Eljefegeneo

Still trying to learn
Local time
Yesterday, 22:51
Joined
Jan 10, 2011
Messages
899
I have been trying to figure out a way to copy a telephone number that is usually in the format (800)-555-1212 into a form. The form is formatted for telephone numbers so the input mask is (???)-???-????. Right now when I copy the number to the telephone control it only pastes the area code. While the above is the usual format for a telephone number that I am copying, there are other formats like ???.???.???? and ???-???-????. Any suggestions on how I might do this? Thanks.
 
I have been trying to figure out a way to copy a telephone number that is usually in the format (800)-555-1212 into a form. The form is formatted for telephone numbers so the input mask is (???)-???-????. Right now when I copy the number to the telephone control it only pastes the area code. While the above is the usual format for a telephone number that I am copying, there are other formats like ???.???.???? and ???-???-????. Any suggestions on how I might do this? Thanks.
Normally in Access (especially), and even (preferably) in Excel, we don't copy and paste. Anything. We write code to set a value equal to something.

I assume you have some code of some kind - you should post it or else we're just guessing
 
No, I am getting a number from a web page and copying it, then pasting it to the forms telephone number field. I was hoping that there would be a simple anser for this, but perhaps I need to have an unbound field, to which I copy the formatted telephone number then when I do something like double click it, strips the unwanted characters and then I can copy and pasted it to the telephone field. If it is only numbers say 8005551212 it will copy perfectly.
 
Update: Using the function found in a previous post, fStripIllegal, which I modified to include some additional characters, I went through my usual trial and error method of solving problems and came up with the following function. First I added an unbound control to the form and called it txtTel. Now when I paste the telephone number into this control it automatically adds the corrected formatted telephone number to my Telephone field which has an input mask. The function is in the OnChange() event of the unbound control txtTel.

Code:
Function UpdateTel()
If Me.Dirty Then
Me.Dirty = False
End If

Dim NewTel As String
  NewTel = txtTel
     fStripIllegal NewTel
         Me.txtTel = Trim(NewTel)
             txtTel = Replace(txtTel, " ", "")
                  Me.Telephone = Format(Me.txtTel, "(###) ###-####")
End Function
I had to add the Tim and Replace features to delete any spaces and then I had to reformat the string of numbers so that it pasted correctly.
Thanks to everyone who helped on this. Much appreciated.
 
Isn't that then storing the format?, when I would have thought you just want the numbers and apply thr format when showing them?
 
I don't know if I can answer that question. The Telephone field is a text field with the input mask of !\(999") "000\-0000;0;_
When pasting the text (number) into the telephone field it is only a continuous string. The control on the form shows it to be (XXX)-XXX-XXXX.

In any case, my question is solved to my satisfaction, which I have been told in many previous posts, if you like it and it works, you have solved your problem. May not be the best or easiest resolution, but it is solved. Thanks.

My money is on Tampa Bay. got my $1 in the other day.
 

Users who are viewing this thread

Back
Top Bottom