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!

update phone number function

Status
Not open for further replies.

yld53x

Programmer
Oct 9, 2002
8
0
0
AU
hi

i'm importing a table with phone numbers (home and mobile) eg (07) 555555 and (0412) 00000.

in design query how can i get rid of the () and leave it at 07555555 and 041200000.

thanks
 
run update query on it
try iff(Mid(homephone,4,1=")",Mid(homephone,2,2) & Mid(homephone,6,10), Mid(homephone,2,4) & Mid(homephone,7,10))

if it it has a problem you will have to write something like that in a code and run it on your table
 

i've have ago at it.

thanks for the quick reply kozia
 
i've typed in the function and it comes back with "function containing the wrong amount of arguements"
 
Oh I know what the problem is the coma's try this if it still gives you an error write a subroutine.
iff((Mid(homephone,4,1=")")),(Mid(homephone,2,2) & Mid(homephone,6,10)), (Mid(homephone,2,4) & Mid(homephone,7,10)))

the subroutine will go something like this
sub updateit()
Dim dbs As Database
Dim rstSet As DAO.Recordset
Dim tmpPhone as string

set dbs=currentdb
set rstSet=dbs.OpenRecordset("tablename")

rstSet.MoveFirst

do until rstSet.EOF
rstSet.Edit
tmpPhone=rstSet![phonefield]
if Mid(tmpPhone,4,1=")") then
rstSet![homephone]=Mid(tmpPhone,2,2) & Mid(tmpPhone,6,10)
else
rstSet![homephone]=Mid(tmpPhone,2,4) & Mid(tmpPhone,7,10)
rstSet.Update
rstSet.MoveNext
loop

end sub

This should work
 
oh oh I found another error
iff((Mid(homephone,4,1)=")"),(Mid(homephone,2,2) & Mid(homephone,6,10)), (Mid(homephone,2,4) & Mid(homephone,7,10)))
and in the subroutine change line
if Mid(tmpPhone,4,1=")") then
to
if Mid(tmpPhone,4,1)=")" then

this should work

 
thanks kozia

it works now

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top