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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Function used to REPLACE char in string 3

Status
Not open for further replies.

Dylan

MIS
Aug 27, 1998
109
US
I need to replace the - (dash) char in a string. Is there a function to do this ???<br>an example of the string is<br><br>377-44-2447<br><br>I need to replace the dashes with a space character.<br><br>Thanks
 
When listing the functions in Access I could not find a REPLACE function ???<br><br>Do you know how I can get to this function ???
 
Check help index on &quot;Replace&quot;. This is what I show in Access 2000:<br>Replace(expression, find, replace[, start[, count[, compare]]])
 
Iam using Access '97 and this function is not listed in the functions index ???<br><br>Is this new to Access 2000 ???
 
If you do not have a Replace function then just create an update query.<br><br>Set the Update To row for the field you want to replace to this:<br>left(fld,3) & &quot; &quot; & mid(fld,5,2) & &quot; &quot; & right(fld,4)<br><br>where fld=yourfieldname <br>there is a space between the quotes<br>be sure to make a copy of your original table first in case you mistype something in the update query<br><br>I hope this helps<br><br>
 
Public Function Replace(oldstring, newletter, oldletter) As String<br>Dim i As Integer<br>i = 1<br><br>Do While InStr(i, oldstring, oldletter, vbTextCompare) &lt;&gt; 0<br>Replace = Replace & Mid(oldstring, i, InStr(i, oldstring, oldletter, vbTextCompare) - i)&nbsp;&nbsp;_<br>& newletter<br>i = InStr(i, oldstring, oldletter, vbTextCompare) + Len(oldletter)<br>Loop<br>Replace = Replace & Right(oldstring, Len(oldstring) - i + 1)<br>End Function<br><br>HTH<br>RDH <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top