Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

sql syntax error with insert into

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kaosyeti - 17 May 2007 22:29 GMT
this is the code that's giving me a syntax error:

strSql = "insert into tblnewoptions (Option, OptionCode, AllocGroup) values
('" & Me.txtboxOption & "'" & ", '" & Me.txtboxOptionCode & "'" & ", '" & Me.
txtboxAllocGroup & "');"
Debug.Print strSql
CurrentDb.Execute strSql

and here is the debug.print line:

insert into tblnewoptions (Option, OptionCode, AllocGroup) values('test desc',
'test code', 'test alloc');

the three test values are being pulled from text boxes on a form.  this code
is in a button on that form.

hope this is an easy one.  any ideas?  thanks.

greg

Signature

Greg

Dave Smith - 17 May 2007 23:09 GMT
Greg,

The syntax problem in your statement is related to the word Option.  This is
not a great field name since it is a Keyword.  If you must use it you can
simply enclose it in square brackets as in:

insert into tblnewoptions ([Option], OptionCode, AllocGroup) values('test
desc',
'test code', 'test alloc');

I tested this and it worked fine in Access 2000.

HTH,

Dave Smith

> this is the code that's giving me a syntax error:
>
> insert into tblnewoptions (Option, OptionCode, AllocGroup) values('test desc',
> 'test code', 'test alloc');
kaosyeti - 18 May 2007 16:30 GMT
that fixed it.  i knew enough to stay away from 'date' and 'year' and a
handful of others, but never thought that 'option' was a keyword.  thanks!

>Greg,
>
[quoted text clipped - 16 lines]
>> insert into tblnewoptions (Option, OptionCode, AllocGroup) values('test desc',
>> 'test code', 'test alloc');

Signature

Greg

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.