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

Remove replace text in a table using VBA

Status
Not open for further replies.

oxicottin

Programmer
Jun 20, 2008
353
0
0
US
Hello, I have a table (tbl_RemovePhrases) that has a text field (strPhrase) that has a bunch of phrases and a field (Delete) that is a yes/no. I need to run code from a button that would use this table (tbl_RemovePhrases) to remove/replace if the yes/no field is true in a table called (tbl_ImportedTabDelimited). This table has to have the phrases removed and replaced with "" and its field is called (Long Discription). How can I do this? Thanks!

Thanks,
SoggyCashew.....
 
Not enough information:

Tables:[pre]
tbl_RemovePhrases tbl_ImportedTabDelimited

strPhrase Long Discription
Delete
[/pre]

How are those 2 tables related?
What is the PK and FK relation here?

BTW, Delete is vary bad name for the field, IMHO :)

Have fun.

---- Andy
 
Code:
DELETE * FROM tbl_ImportedTabDelimited 
INNER JOIN strRemovePhrases ON [Long Discription] = strPhrase 
WHERE [Delete] = "yes"

Not tested

Randy
 

I think oxicottin wants to use UPDATE statement (not DELETE):

the phrases removed and replaced with ""

since (I would guess) (s)he does not want to delete records, just update them.

Have fun.

---- Andy
 
Yes if the yes/no field (tbl_RemovePhrases)(Delete) is false then remove the text phrase that's in the (tbl_RemovePhrases) field (strPhrase)from the table (tbl_ImportedTabDelimited)field (Long Discription). I need to loop threw to get all the trues.

Example:

1) (tbl_RemovePhrases) yes/no filed(Delete) = false
2) If false remove the phrase (tbl_RemovePhrases) Text field(strPhrase) = and one year old.
3) From (tbl_ImportedTabDelimited) Text field(Long Discription) = The cat is black and one year old.
4) Now here is the remaining text from the phrase that was found in (Long Discription) = The cat is black
5) loop




Thanks,
SoggyCashew.....
 
We still don't know how those 2 tables relate to each other. Which field do they have in common (PK-FK)?

And logical issue here:
" yes/no field (tbl_RemovePhrases)(Delete) is false "

Wouldn't that be:
yes(DO Delete)/no(DON'T Delete) field (tbl_RemovePhrases)(Delete)

Or is that a 'backward' logic here....?
It may be just me... :)

Have fun.

---- Andy
 
So, replace my query with an UPDATE query.
Same basic idea, isn't it?


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top