Full Version: Australian Phone Numbers - Entry, Storage And Display
UtterAccess Forums > Microsoft® Access > Access Forms
I'm about to build a contact database - who isn't.
intend to store just the digits of phone numbers with the exception of a "+" sign for international numbers, i.e., disregard any spaces or brackets or whatever in the table itself.
Users may be used to enter numbers with 'their' format which does include non-digit characters. What's an easy way to strip the non-digit characters.
I'd like to display phone numbers on forms and reports in a gernerally accepted format, unfortunately, different types of numbers do have different formats. Here in Australia the most common ones (I can think of) are: (n for any digit)
Regular Landline 0n nnnn nnnn
Regular Mobile 04nn nnn nnn
Some long Special 1300 nnn nnn or 1500 nnn nnn or 1800 nnn nnn or 1900 nnn nnn
Some short Special 13 nn nn
International +n[n][n] and then just all digits, it would be futile trying to accommodate the various international formatting preferences, particularly as few international numbers are expected to be used.
Surely this is a type of nut that has been cracked many times before - thanks in advance for input
I think you should be able to write a quick function to strip anything out of the input that isn't numeric. Just call it on the form's BeforeUpdate event...
'untested but should be pretty close
Public Function FormatRawPhoneNum(sInput As String) As String
  Dim Ret As String, i As Integer
  For i = 1 To Len(sInput)
    If IsNumeric(Mid(sInput, i, 1)) Then
      Ret = Ret & Mid(sInput, i, 1)
    End If
  FormatRawPhoneNum = Ret
End Function

I'm not quite sure how to accomplish the re-formatting for the second. You could probably write a function to handle this as well but it would be a bit involved I think. I'll wait around to see if someone already has something ohyeah.gif
I disagree with point one:
I'm storing my numbers as a string which means that I'm storing all the pritties
My application is intended for use in USA so I have a consistant formating for my project (916) 555-1234
If I'm wrong I would like to be corrected
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.