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

Repace a carscter with another one

Status
Not open for further replies.

lb1

Technical User
Apr 19, 2002
109
0
0
US
In Access I would like to replace a specific character (for ex $ by Dol). I would like to write a query in the query bject and use a statement looking like replace("$","Dol"). Is it possible to do this and How can I do it?
Thanks.
Louis
 
Check the InStr() function:

InStr Function Example
This example uses the InStr function to return the position of the first occurrence of one string within another.

Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".

' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)

' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString, SearchChar, 0)

' Comparison is binary by default (last argument is omitted).
MyPos = Instr(SearchString, SearchChar) ' Returns 9.

MyPos = Instr(1, SearchString, "W") ' Returns 0.

Jim DeGeorge [wavey]
 
Access 2k has a Replace function...check that out if you have 2k.

Kevin
 
I have version 2000, but where do I use this 'replace' function?
 
To use the Replace function, you have to put it in a module like this.

Function myReplace(myStr as String) as String
myReplace = Replace(myStr,"$","Dol")
End Function

and then call it from the query by putting something like this on the Field line of your query.

ReplacedValues:myReplace([FieldNameHere])

That should do it.

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top