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

Like Help

Status
Not open for further replies.

MadMax7

MIS
Feb 17, 2004
62
GB
I am trying to write a module with the following code

If Name like '*119*' Then
CorrectName = "Macclesfield " & Name
elseif Name like '*118*' Then
CorrectName = "Stockport " & Name

End If

i need to run this code for about a 1000 different outcomes but the code is stopping and highlighting the first ' in the code hope someone can help me sort this out
 
In VBA, the single quote is a comment introducer.
If Name Like [!]"[/!]*119*[!]"[/!] Then
CorrectName = "Macclesfield " & Name
ElseIf Name Like [!]"[/!]*118*[!]"[/!] Then
CorrectName = "Stockport " & Name
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You may be confusing VBA with T-SQL here. VBA needs double quotes.

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top