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

Text ending in quotes cause syntax error

Status
Not open for further replies.
Mar 24, 2004
13
0
0
US
I am using the following code to select a record from a combo box, but when I select a record with text that ends or contains quotes I get a syntax error.

DetailTB.Open "Update Detail set [added]='1' Where LineName = """ & Me!LineName & """"

Example: #19 B-6-11 Lateral 8" causes the following error
Syntax error in string query expression 'Line Name = "#19 B-6-11 Lateral 8"'".
 
You're using both " and ' as string specifiers in your statement. Try using ' in the where clause
 
Your 4 closing quotes are producing two (not just one) double quote at the end. Try this
[blue][tt]
Where LineName = """ & Me!LineName & """
[/tt][/blue]
 
It worked, thank you so much!

I triend Where LineName = '" & Me!LineName & "'
 
You might want to look at the FAQ in the VB & Databases forum entitled "Single Quotes are causing problems".

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top