HomeGrowth
Technical User
I try to insert a record into a table (only 2 fields). At the cn.Execute, I have this run-time error ‘-2146217900(80040e14)’: Syntax error in INSERT INTO Statement.
I think that I am missing something in function, can you help me out?
Function CreateRefNo(sReportNumber As String, sRefNo As String) As Boolean
Dim sSql As String
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection ' This establishes the connection
sSql = "INSERT INTO tbl(2)ReferenceReportNo ( [ReportNumber], [RefReportNumber] ) VALUES ('" & sReportNumber & "','" & sRefNo & "');"
cn.Execute (sSql)
Exit_CreateRefNo:
cn.Close
Exit Function
Err_CreateRefNo:
MsgBox Err.Number & " ' " & Err.Description
Resume Exit_CreateRefNo
End Function
I think that I am missing something in function, can you help me out?
Function CreateRefNo(sReportNumber As String, sRefNo As String) As Boolean
Dim sSql As String
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection ' This establishes the connection
sSql = "INSERT INTO tbl(2)ReferenceReportNo ( [ReportNumber], [RefReportNumber] ) VALUES ('" & sReportNumber & "','" & sRefNo & "');"
cn.Execute (sSql)
Exit_CreateRefNo:
cn.Close
Exit Function
Err_CreateRefNo:
MsgBox Err.Number & " ' " & Err.Description
Resume Exit_CreateRefNo
End Function