Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 How To Fetch Certain Lengths Of Text From Fields

Author  Topic 

murtzzz
Starting Member

14 Posts

Posted - 2007-07-24 : 04:39:31
Hi.

Im trying to script out the mobile numbers of all patients registered in our system. The problem is.. the field has so much inconsistency, its hard to get the 11 digit number. Some numbers are like 077 777 7777, or 0778 6365 644 or 07865 074962

Im trying to write some code in access that will allow me to get all digits in the mobile number.

Im currenty writing code that has the MID function.. where Im saying 'if there is a space in the 6th character.. pull the first 12 digits of the field... if there is a space in the 6th and 10th character, pull the first 13 digits'

heres the code I have so far.. I keep on getting errors!

Mob: IIf (Mid([telephone],6,6) like "* *" or Mid([telephone],4,4) like "* *" or Mid([telephone],7,7) like "* *",Mid([telephone],1,12),Mid([telephone],1,11),
IIf Mid([telephone],6,6) like "* *" and Mid([telephone],10,10) like "* *",Mid([telephone],1,13),Mid([telephone],1,11)))

Please help!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-07-24 : 06:38:21
a = replace(a," ","")

ie replace all the spaces in "a" with nothing!!
Go to Top of Page
   

- Advertisement -