?
Solved

Syntax for UPDATE...LIKE in vb module

Posted on 2008-11-12
2
Medium Priority
?
272 Views
Last Modified: 2012-05-05
I'm trying to clean up some data in Access 2000, so I want to capture anything 'like' a string of text and update it.  There are going to be 30 variations of below so I'm storing them in a module rather than writing a bunch of separate queries; I just need to know what's wrong with WHERE statement that gives me the syntax error:

Public Sub doUpdates()
Dim mysql As String
mysql = "UPDATE tblTerritory_AnalysisFINAL " & _
"SET tblTerritory_AnalysisFINAL.Terr_Name = 'Health Insurance'" & _
"WHERE tblTerritory_AnalysisFINAL.Terr_Name= LIKE '*Health Insurance*'"
 
DoCmd.RunSQL mysql
End Sub

Open in new window

0
Comment
Question by:jimshock
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 22941918


Public Sub doUpdates()
Dim mysql As String
mysql = "UPDATE tblTerritory_AnalysisFINAL " & _
" SET tblTerritory_AnalysisFINAL.Terr_Name = 'Health Insurance'" & _
" WHERE tblTerritory_AnalysisFINAL.Terr_Name LIKE '*Health Insurance*'"
 
DoCmd.RunSQL mysql
End Sub
0
 

Author Closing Comment

by:jimshock
ID: 31516025
Awesome!  Fast and dead-on.  Thanks so much, capricorn1 !
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question