Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting phone numbers and zip codes???

Status
Not open for further replies.

jmlbones

Technical User
Jul 16, 2001
13
US
I have a table that stores phone numbers and zip codes as text format. A phone number looks like this 1112223333 and a zip looks like this 111112222. I am trying to export to a fixed length text file that requires phone numbers like this 111/222-3333 and zips like this 11111-2222. Is there an expression I can use in the query that I am using to export the data to allow the text file to be populated appropriately? Or, any other suggestion?
 
The format function will allow you to do this.

Phone number field:
[tt]
FormattedPhone: Format([MyPhoneField],"(###) ###-####")
[/tt]

For the zip code it can be a little trickier, you have to test for a 9 digit or 5 digit zip, then apply the formatting.
[tt]
FormattedZip: IIf(Len([MyZipField])=5,Format([MyZipField],"00000"),Format([MyZipField],"00000-0000"))
[/tt]

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top