I am trying to update one of my tables using VBA. My code is as follows:
Sub UpdateChildAccounts(selItem As String)
Dim wrkJet As DAO.Workspace
Dim db As DAO.Database
Dim dbname As String
Dim rs As DAO.Recordset
Dim strSQL As String
Dim Q As DAO.QueryDef
dbname = "C:\Documents and Settings\Sanju\Desktop\Project\Commcare.mdb"
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase(dbname, , True, "Microsoft.Jet.OLEDB.3.51")
Set Q = db.CreateQueryDef("")
strSQL = "UPDATE ClientAccountMapping" & _
" SET (ClientAccountMapping.InvoiceCode)='RBK'" & _
" WHERE (((ClientAccountMapping.InvoiceCode)='" & selItem & "'));"
Q.Sql = strSQL
Q.Close
End Sub
I am getting a syntax error in UPDATE query. I cannot see anything wrong in there. I hope some can help me to find my error.
Thanks a lot for u r help in advance.
Sanjna...
Sub UpdateChildAccounts(selItem As String)
Dim wrkJet As DAO.Workspace
Dim db As DAO.Database
Dim dbname As String
Dim rs As DAO.Recordset
Dim strSQL As String
Dim Q As DAO.QueryDef
dbname = "C:\Documents and Settings\Sanju\Desktop\Project\Commcare.mdb"
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase(dbname, , True, "Microsoft.Jet.OLEDB.3.51")
Set Q = db.CreateQueryDef("")
strSQL = "UPDATE ClientAccountMapping" & _
" SET (ClientAccountMapping.InvoiceCode)='RBK'" & _
" WHERE (((ClientAccountMapping.InvoiceCode)='" & selItem & "'));"
Q.Sql = strSQL
Q.Close
End Sub
I am getting a syntax error in UPDATE query. I cannot see anything wrong in there. I hope some can help me to find my error.
Thanks a lot for u r help in advance.
Sanjna...