If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Access equivalent of str_replace() function
Hello,
Is there an Access equivalent of the str_replace() function? Here's my dilemma: In an Access '97 table, I have a text field containing item descriptions. The process that imported the data from another database has inserted a "~;~" (minus the quotes) in random locations within most of the descriptions (with multiple instances of the insertion in a few of the descriptions). I'd like to run a query from that data, removing the "~;~" or replacing it with spaces. Is there a way to do that? Sincerely, Don Hicks Portland, Oregon |
#2
|
|||
|
|||
Access equivalent of str_replace() function
Hi Don
Here's a function that I've been using.. Public Function ReplaceString(ByVal varCurrentValue, strOld As String, strNew As String) Dim strNewText As String Dim intStart As Integer, intRight As Integer If Len(Nz(varCurrentValue, "")) 0 Then ' Get position of first strOld to start loop intStart = InStr(varCurrentValue, strOld) If intStart = 0 Then ReplaceString = varCurrentValue Else ' Loop until no more strOlds found in current field Do Until intStart = 0 ' Get position of first strOld intStart = InStr(varCurrentValue, strOld) ' Get end position of strOld intRight = intStart + Len(strOld) ' Set variable for new text to characters to left ' and right of strOld, inserting strNew ' in place of strOld strNewText = Left(varCurrentValue, intStart - 1) & strNew & Mid(varCurrentValue, intRight) varCurrentValue = strNewText ' Get position of next strOld intStart = InStr(varCurrentValue, strOld) Loop ReplaceString = strNewText End If End If Hope this helps Best regards Maurice St-Cyr Micro Systems Consultants, Inc Hello, Is there an Access equivalent of the str_replace() function? Here's my dilemma: In an Access '97 table, I have a text field containing item descriptions. The process that imported the data from another database has inserted a "~;~" (minus the quotes) in random locations within most of the descriptions (with multiple instances of the insertion in a few of the descriptions). I'd like to run a query from that data, removing the "~;~" or replacing it with spaces. Is there a way to do that? Sincerely, Don Hicks Portland, Oregon |
#3
|
|||
|
|||
Access equivalent of str_replace() function
Have you considered opening the table in datasheet view and selecting
Edit|Replace? This is quite handy if you only have to do this once. -- Duane Hookom MS Access MVP -- "Don Hicks" wrote in message ... Hello, Is there an Access equivalent of the str_replace() function? Here's my dilemma: In an Access '97 table, I have a text field containing item descriptions. The process that imported the data from another database has inserted a "~;~" (minus the quotes) in random locations within most of the descriptions (with multiple instances of the insertion in a few of the descriptions). I'd like to run a query from that data, removing the "~;~" or replacing it with spaces. Is there a way to do that? Sincerely, Don Hicks Portland, Oregon |
#4
|
|||
|
|||
Access equivalent of str_replace() function
Hey Duane,
I don't know about the tilde-semicolon-tilde thingie, but the Edit/Replace doesn't work very well in A97 (SR2). At least, it doesn't "see" the special characters ("The search item was not found.") See my reply to AZEye, "Removing a "." Update query". Cheers, LeAnne Duane Hookom wrote: Have you considered opening the table in datasheet view and selecting Edit|Replace? This is quite handy if you only have to do this once. -- Duane Hookom MS Access MVP -- "Don Hicks" wrote in message ... Hello, Is there an Access equivalent of the str_replace() function? Here's my dilemma: In an Access '97 table, I have a text field containing item descriptions. The process that imported the data from another database has inserted a "~;~" (minus the quotes) in random locations within most of the descriptions (with multiple instances of the insertion in a few of the descriptions). I'd like to run a query from that data, removing the "~;~" or replacing it with spaces. Is there a way to do that? Sincerely, Don Hicks Portland, Oregon |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Images in a database | Franz | General Discussion | 10 | October 7th, 2004 09:35 AM |
Access License In Terminal Server | JIM.H. | General Discussion | 9 | July 19th, 2004 12:32 AM |
Data Access Page Problem | Doug Munich | General Discussion | 0 | June 5th, 2004 12:03 AM |
Function name Access can't find | Terry | New Users | 6 | May 4th, 2004 05:09 AM |
Using Excel WorksheetFunction.Mode function in Access VBA | ANE | Worksheet Functions | 2 | December 12th, 2003 02:38 AM |