I have a form (frm_approval) which is based on a query (qry_unapproved ). The query queries a table (tbl_total) for records that are unapproved and shows these records in (frm_approval) so the approver can use the form to approve them via checking a check box.
The form is set to Continuous View and I get many rows of textboxes (RecordName & RecordQty), each row for 1 record to be approved. For every record, I have a checkbox field (chkbox) which will be uncheck when the form opens up.
My idea is for the approver to check the records he approves and clicks on an command button that requery the form. (tbl_total) will be updated and everyone is happy.
Now there is a qty for each record. When the record is approved, the approved qty should be deducted from an inventory table (tbl_inventory)
Now, I coded into the command button the following VBA code:
=============== =============== =============== =======
Private Sub Commandbutton_A pproveRequests_ Click()
Dim db As DAO.Database
Dim recset As DAO.Recordset
If chkbox = True Then
Set db = CurrentDb()
Set recset = db.OpenRecordse t("tbl_inventor y", dbOpenDynaset)
recset.FindFirs t "RecordName = '" & Me.RecordName & "'"
recset.Edit
recset!RecordQt y = recset!RecordQt y - Me.RecordQty
recset.Update
End If
Me.Requery
'Me refers to frm_approval
End Sub
=============== =============== =============== =====
The problem here is that when I check more than 1 record, only the qty of 1 record (the most bottom checked record) gets updated in (tbl_inventory) . How do I make it such that any checked record qty gets updated in (tbl_inventory) ?
The form is set to Continuous View and I get many rows of textboxes (RecordName & RecordQty), each row for 1 record to be approved. For every record, I have a checkbox field (chkbox) which will be uncheck when the form opens up.
My idea is for the approver to check the records he approves and clicks on an command button that requery the form. (tbl_total) will be updated and everyone is happy.
Now there is a qty for each record. When the record is approved, the approved qty should be deducted from an inventory table (tbl_inventory)
Now, I coded into the command button the following VBA code:
=============== =============== =============== =======
Private Sub Commandbutton_A pproveRequests_ Click()
Dim db As DAO.Database
Dim recset As DAO.Recordset
If chkbox = True Then
Set db = CurrentDb()
Set recset = db.OpenRecordse t("tbl_inventor y", dbOpenDynaset)
recset.FindFirs t "RecordName = '" & Me.RecordName & "'"
recset.Edit
recset!RecordQt y = recset!RecordQt y - Me.RecordQty
recset.Update
End If
Me.Requery
'Me refers to frm_approval
End Sub
=============== =============== =============== =====
The problem here is that when I check more than 1 record, only the qty of 1 record (the most bottom checked record) gets updated in (tbl_inventory) . How do I make it such that any checked record qty gets updated in (tbl_inventory) ?
Comment