Simple question, how can I take something entered in a textbox and enter it into QuickBooks from Access. I have no problems with connecting Access to QuickBooks but am receiving a syntax error.
This hard coded input works:
sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"
sSQL = "Insert into customer (Name) values ('Testing VB')"
Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConnection.Open sConnectString
oConnection.Execute (sSQL)
sMsg = sMsg & "Record Added!!!"
MsgBox sMsg
Set oRecordset = Nothing
Set oConnection = Nothing
End Sub
This is what I am trying to get to work (input from text box):
cust = Forms.form1.customerName
sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"
sSQL = "Insert into customer (Name) values" & cust & ")"
Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConnection.Open sConnectString
oConnection.Execute (sSQL)
sMsg = sMsg & "Record Added!"
MsgBox sMsg
Set oRecordset = Nothing
Set oConnection = Nothing
End Sub
Update (what about multiple entries at once?
cust = Forms.form1.customerName
company = Forms.form1.companyName
sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"
sSQL = "Insert into customer (Name), (CompanyName) values ('" & cust & "'), ('" & companyName & "') "