I have an access database that handle sales and shipping. In the shipment form, user can click a button to take following actions.
1. Check largest invoice number in the order table [DBA_order_header] then add 1 as new invoice number to be assigned to current order record.
2. Add new record to two tables associate to invoice payment: [DBA_inv_payment] and [DBA_inv_pymt_deduction].
There is also a cancel button to supposedly cancel the assignment of new invoice number in tables [DBA_order_header] and remove records in tables [DBA_inv_payment], and [DBA_inv_pymt_deduction]
However, the cancel button with following SQL vba statement is not working on deleting records in the two payment tables. After user click the Cancel button, the newly added records in these two table are not deleted. I cannot figure out what went wrong with the vba codes. Can someone point out what is wrong with the vba code? Thanks in advance.
Expand|Select|Wrap|Line Numbers
- Dim dbs As Database
- Set dbs = CurrentDb
- Dim strOrder As String
- strOrder = Me.TxtOrderNo
- MsgBox strOrder, vbOKOnly
- dbs.Execute "Delete [DBA_inv_payment]* from" _
- & "[DBA_inv_payment] WHERE [pymt_invoice_no] = " & strOrder & ";"
- dbs.Execute "Delete [DBA_inv_pymt_deduction]* from" _
- & "[DBA_inv_pymt_deduction] WHERE [pymd_invoice_no] = " & strOrder & ";"
- dbs.Close
- Me.Recordset.Requery