Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi feelas,

Please help be out see my code below...Im using Access2003 and the error is due to insert into statement. Can you help me out find what's wrong with the code below? Thanks in advance. God bless and more power!

Dim dbs As Database
  Dim cmd As New ADODB.Command
  Dim strsql As String

strsql = "INSERT INTO PACRLog[PONumber] VALUES '" & PONumbertxt.Text & "'"

With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandText = strsql
    cmd.Execute
End With
Posted
Comments
Mahendran Murugesan 16-Dec-13 23:51pm    
Use the query as
strsql = "INSERT INTO PACRLog (PONumber) VALUES '" & PONumbertxt.Text & "'"

User ( instead of [

1 solution

You forgot parenthesis & place parenthesis instead of square brackets. And See below
VB
strsql = "INSERT INTO PACRLog(PONumber) VALUES ('" & PONumbertxt.Text & "')"

Check the syntax SQL INSERT INTO Statement[^]

And use parametrized queries to avoid SQL Injection[^]
 
Share this answer
 
Comments
Ariel Riyo 17-Dec-13 0:13am    
You nailed it! Thanks!
thatraja 17-Dec-13 0:17am    
welcome, And I suggest you to learn SQL for sometime to save your massive time.
Maciej Los 17-Dec-13 2:02am    
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900