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

Comparing values to a table

Status
Not open for further replies.

daybase

Technical User
Dec 13, 2002
115
GB
I am using the replace command to remove html coding from a text file used as a memo field in another application which I am now using for my own purposes. Being very very new to code I have a list of replacements such as

stripfile = replace(stripfile, "</font>", "")
stripfile = replace(stripfile, "<p>", "")

This is all coded but I would like to be able to hold a table of replacements - the code that needs replacing in one field and what it should be replaced with and then the function just skips through the table carrying out any replacements where necessary. My coding is lousy and my efforts dont work so without asking anybody to do my programming for me could anybody give me some pointers (and a snippet or two of code) to guide me in the right direction.
 
Maybe looping through a recordset?
-- Not Tested --
Code:
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String

strSQL = "SELECT * FROM myTable"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
With rs
    .MoveFirst
    Do Until .EOF
        stripfile = replace(stripfile, rs!Field1, rs!Field2)
        .MoveNext
    Loop
End With
Set rs = Nothing
Set db = Nothing




Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top