Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 20th, 2006, 04:21 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default formatting data

Hi,

I have table with fields 'phone' and 'fax'.
The data in these fields is in different formats like xxx-xxx-xxxx or xxx.xxx.xxxx or xxxxxxxxxx. I need to change the format of all data to one format.
How can I do that ? Can it be done thru SQL ?

Thanks
Reply With Quote
  #2 (permalink)  
Old December 21st, 2006, 05:52 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Salisbury, Wiltshire, United Kingdom.
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

It can be done in SQL, but I think your easiest approach, assuming this is a one off task, is to write a function which you can modify for each format type you have... something like:

================================================== ================================
Public Function pfunAmendPhoneFormat(strInput As String, strRemove As String) As String
Dim strTemp As String
Dim intLocator As Integer

intLocator = InStr(strInput, strRemove)

Do While intLocator > 0
   strTemp = strTemp & Left(strInput, intLocator - 1)
   strInput = Right(strInput, Len(strInput) - intLocator)
   intLocator = InStr(strInput, strRemove)
Loop

If Len(strInput) > 0 Then strTemp = strTemp & strInput

pfunAmendPhoneFormat = strTemp

End Function
================================================== ================================

strInput is your input string, ie: the Telephone number you want to change "xxx-xxx-xxxx"
strRemove is the specific key you want to remove, ie: "-"

It could probably do with tidying up a bit too, but it seems to do the job. You need to run it through a query to do the update to your table... and you will need to change the strRemove for each type of character you want to remove, but it should put you in the right direction...

Good luck.
Reply With Quote
  #3 (permalink)  
Old December 22nd, 2006, 11:27 AM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for helping.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting data skrj02 Access 1 December 23rd, 2006 02:35 PM
Formatting Data Entry in forms aRtware Access 5 May 12th, 2006 09:16 AM
General data formatting MargateFan XSLT 1 April 26th, 2006 06:53 AM
Formatting data in MsFlexGrid - How ? mike123abc Pro VB 6 2 January 8th, 2004 10:20 PM



All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.