Replace

  • Thread starter DMUM via AccessMonster.com
  • Start date
D

DMUM via AccessMonster.com

Hello I have been using the following code to replace text in a table with
changes made by the User. It seemed to work fine until today when I tried to
change US to United States. It went through all the fields in the table and
replaced everything containing a US with United States. i.e Australia became
AUnited Statestralia. I looked at the MS Help and it seems I have all the
requirements in my query. I need it to find and replace WHOLE FIELD, not ANY
PART OF FIELD. The MS help didn't indicate anything in the code to specify
this unless I am missing something.

strSQL = "UPDATE tblImportExcel " & _
"SET tblImportExcel." & Me.txtColName & " = " & _
"Replace([" & Me.txtColName & "],""" & Me.txtFind & """, """ & Me.
txtEdit & """) "

Thanks
 
W

Wayne Morgan

Add a WHERE clause to limit the records to only those that have US in the
field and update that to United States.

Example:
strSQL = "UPDATE tblImportExcel SET tblImportExcel." & Me.txtcolName & " =
""" & Me.txtEdit & """ WHERE tblImportExcel." & Me.txtcolName & " = """ &
Me.txtFind & """"

This should also run much quicker than using the Replace() function.
 
D

DMUM via AccessMonster.com

AWESOME!!!!

Thank you Thank you

Wayne said:
Add a WHERE clause to limit the records to only those that have US in the
field and update that to United States.

Example:
strSQL = "UPDATE tblImportExcel SET tblImportExcel." & Me.txtcolName & " =
""" & Me.txtEdit & """ WHERE tblImportExcel." & Me.txtcolName & " = """ &
Me.txtFind & """"

This should also run much quicker than using the Replace() function.

Just curious, why should it work quicker?
Hello I have been using the following code to replace text in a table with
changes made by the User. It seemed to work fine until today when I tried
[quoted text clipped - 17 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top