A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access equivalent of str_replace() function



 
 
Thread Tools Display Modes
  #1  
Old August 13th, 2004, 04:58 PM
Don Hicks
external usenet poster
 
Posts: n/a
Default 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  
Old August 13th, 2004, 05:14 PM
StCyrM
external usenet poster
 
Posts: n/a
Default 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  
Old August 13th, 2004, 05:21 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default 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  
Old August 13th, 2004, 06:10 PM
LeAnne
external usenet poster
 
Posts: n/a
Default 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

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 11:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.