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

Insert query syntax error

Status
Not open for further replies.

Bobnz

IS-IT--Management
Aug 19, 2002
116
NZ
Hi getting a syntax error with this query

Code:
strSQL = "INSERT INTO order"
    strSQL = strSQL + "(clientname, supplierid, productid, quantity, comment, dateordered  )"
    strSQL = strSQL + " values (" & Me!txtclientname & "," & Me!cmboven.Column(1) & ""
    strSQL = strSQL + " ," & Me!cmboven.Column(0) & ", " & Me!txtoquantity & ", " & Me!txtocomment & ", " & Me!txtoodate & " )"
    
    DoCmd.RunSQL strSQL

when I type in the following in the immediate window

Code:
?strSQL

it returns

Code:
INSERT INTO order(clientname, supplierid, productid, quantity, comment, dateordered  ) values (brown,2 ,2, 1, very nice, 9/11/2004 )

which looks ok to me???
no doubt something blindingly obvious, if someone
could point it out...

TIA

Bob
 
strSQL = "INSERT INTO order"
strSQL = strSQL + "(clientname, supplierid, productid, quantity, comment, dateordered )"
strSQL = strSQL + " values ([highlight]'[/highlight]" & Me!txtclientname & "[highlight]'[/highlight]," & Me!cmboven.Column(1) & ""
strSQL = strSQL + " ," & Me!cmboven.Column(0) & ", " & Me!txtoquantity & ", [highlight]'[/highlight]" & Me!txtocomment & "[highlight]'[/highlight], [highlight]#[/highlight]" & [highlight]Format([/highlight]Me!txtoodate [highlight], "m/dd/yyyy") & "#[/highlight] )"



Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the reply but thats not it

Bob
 
When you paste the result of ? strSQL in a SQL code view pane of the query design window, what happen ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Got it order must be a reserved word duh "order by"
once I put [order] evrything was fine.

thanks for the replies though.

Bob
 
evrything was fine
Without the addition of single quotes and #s ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
No I needed both single quotes and hash signs

thanks for that.

B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top