PDA

View Full Version : Solved: Syntax error



slamet Harto
09-14-2009, 09:50 PM
Hi there,

Can you help to fix this line, please?
As I have an errorr message "Syntax error in Update Statement"

Thanks for assistance,

msq = "Update TbVouch set CompNm='" & frmVoucherBB.txtCoyNm.Text & "',Route='" & frmVoucherBB.txtRoute.Text & "',Amount='" & frmVoucherBB.TxtAmt.Text & "'," & _
"Qty='" & frmVoucherBB.TxtBoxQty.Text & "',VoucherNo='" & frmVoucherBB.TxtBoxVno.Text & "',In-Out='" & frmVoucherBB.CBoInOut.Text & "'," & _
"Status='" & frmVoucherBB.CboInStat.Text & "'," & _
"VocStat='" & frmVoucherBB.CboStat.Text & "',Comment='" & frmVoucherBB.txtComments.Text & "' where Ltrim(TbVouch.VoucherRegno)='" & frmVoucherBB.lblVoucher.Text & "'"

Cn.Execute (msq)
MsgBox "Update Completed...!!!", vbInformation, "Thank you"

Bob Phillips
09-15-2009, 12:45 AM
msq = "UPDATE TbVouch SET " & _
"CompNm='" & frmVoucherBB.txtCoyNm.Text & "', " & _
"Route='" & frmVoucherBB.txtRoute.Text & "', " & _
"Amount='" & frmVoucherBB.TxtAmt.Text & "', " & _
"Qty='" & frmVoucherBB.TxtBoxQty.Tex & "', " & _
"VoucherNo='" & frmVoucherBB.TxtBoxVno.Text & "', " & _
"In-Out='" & frmVoucherBB.CBoInOut.Text & "', " & _
"Status='" & frmVoucherBB.CboInStat.Text & "', " & _
"VocStat='" & frmVoucherBB.CboStat.Text & "', " & _
"Comment='" & frmVoucherBB.txtComments.Text & "' " & _
"WHERE Ltrim(TbVouch.VoucherRegno)='" & frmVoucherBB.lblVoucher.Text & "'"

cn.Execute (msq)
MsgBox "Update Completed...!!!", vbInformation, "Thank you"

slamet Harto
09-15-2009, 02:16 AM
Hi Bob,

Glad to receiving your reply, however it doesn't work.

Best, Harto

Bob Phillips
09-15-2009, 04:12 AM
Can you post a workbook then so we can see the actual details. Is it an Access DB, if so can you post that as well? What error are you getting now?

Bob Phillips
09-15-2009, 04:14 AM
I just noticed a couple of errors



msq = "UPDATE TbVouch SET " & _
"CompNm='" & frmVoucherBB.txtCoyNm.Text & "', " & _
"Route='" & frmVoucherBB.txtRoute.Text & "', " & _
"Amount='" & frmVoucherBB.txtAMt.Text & "', " & _
"Qty='" & frmVoucherBB.txtBoxQty.Text & "', " & _
"VoucherNo='" & frmVoucherBB.TxtBoxVno.Text & "', " & _
"In-Out='" & frmVoucherBB.CBOInOut.Text & "', " & _
"Status='" & frmVoucherBB.CBoINStat.Text & "', " & _
"VocStat='" & frmVoucherBB.CBOStat.Text & "', " & _
"Comment='" & frmVoucherBB.txtComments.Text & "' " & _
"WHERE Ltrim(TbVouch.VoucherRegno)='" & frmVoucherBB.lblVoucher.Caption & "'"


and there might be a problem with quantity and Amt if they are numeric fields in the database as you are enclosing them with quotes.

slamet Harto
09-15-2009, 12:54 PM
Thanks bob
highly appreciated it
Regards, harto