UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> SQL Insert Into Statement Issue, Access 2016    
 
   
ordnance1
post Jan 23 2020, 03:17 PM
Post#1



Posts: 727
Joined: 7-May 11



I am having an issue with my SQL Insert Into statement.

This is part of a NotInList procedure. If the user enters Bobs Tree Service it works fine but if they enter Bob's Tree Service I get a Syntx error (missing operator) in query expression "Bob's Tree Service');'.

Attached File  Untitled_picture.png ( 7.27K )Number of downloads: 1



CODE
strsql = "INSERT INTO dbo_Business( [Business_Name]) " & _
                                 "VALUES ('" & NewData & "');"
Go to the top of the page
 
Jeff B.
post Jan 23 2020, 04:14 PM
Post#2


UtterAccess VIP
Posts: 10,378
Joined: 30-April 10
From: Pacific NorthWet


JOPO (just one person's opinion)

Looks like the first open parenthesis doesn't have a space before it...

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
RJD
post Jan 23 2020, 04:28 PM
Post#3


UtterAccess VIP
Posts: 10,213
Joined: 25-October 10
From: Gulf South USA


Hi: It's the apostrophe (single quote) in the business name. Try this and see if it works for you ...

strsql = "INSERT INTO dbo_Business([Business_Name]) " & _
"VALUES ('" & Replace([NewData], "'", "''") & "');"

or even just this ...

strsql = "INSERT INTO dbo_Business( [Business_Name]) " & _
"VALUES (""" & [NewData] & """);"

Two ways to accomplish the same result ...

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ordnance1
post Jan 23 2020, 05:02 PM
Post#4



Posts: 727
Joined: 7-May 11



Works great.

Thank you
Go to the top of the page
 
RJD
post Jan 23 2020, 06:27 PM
Post#5


UtterAccess VIP
Posts: 10,213
Joined: 25-October 10
From: Gulf South USA


You are very welcome. Glad that worked for you.

Continued success ...

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st February 2020 - 10:57 AM