Tammysdatabase
Member
- Local time
- Yesterday, 20:36
- Joined
- Mar 18, 2020
- Messages
- 34
I have developed a PO system in my database that works beautifully, however, i'm stuck on the proper code for a command button. I want the command button to "Receive All".
I have a Mainform: Receiving
that has a
Subform: PORecSubfrm
I have placed a command button on the mainform that I would like to have the "Qty Received" field be updated to match the "Quantity Ordered" field, thus will trigger the PO to be marked as "Received" (this part is working in the "after update" for the "Quantity Received" field).
My subform is in datasheet view and filters based on the purchase order number chosen on the mainform.
What I'm grappling with is do I use the control names or the actual field names in my command button code.....I've tried it both ways and can't get it to work and I've tried different ways of writing the code (see below).
My control names on the subform are: QtyReceived & QtyOrdered (fields names for these are mentioned above)
I've tried a couple different ways and I'm not having any success.
I have also tried......
Where am I going wrong?? The code in both of these scenarios gets hung up at the !QtyReceived = QtyOrdered line.
I have a Mainform: Receiving
that has a
Subform: PORecSubfrm
I have placed a command button on the mainform that I would like to have the "Qty Received" field be updated to match the "Quantity Ordered" field, thus will trigger the PO to be marked as "Received" (this part is working in the "after update" for the "Quantity Received" field).
My subform is in datasheet view and filters based on the purchase order number chosen on the mainform.
What I'm grappling with is do I use the control names or the actual field names in my command button code.....I've tried it both ways and can't get it to work and I've tried different ways of writing the code (see below).
My control names on the subform are: QtyReceived & QtyOrdered (fields names for these are mentioned above)
I've tried a couple different ways and I'm not having any success.
Code:
Private Sub cmdReceiveAll_Click()
Dim rs As DAO.Recordset
Set rs = Forms!Receiving!PORecSubfrm.Form.RecordsetClone
With rs
If Not .BOF Then
.MoveFirst
!QtyReceived = QtyOrdered
.Update
End If
End With
Set rs = Nothing
End Sub
I have also tried......
Code:
Private Sub cmdReceiveAll_Click()
Dim rs As DAO.Recordset
Set rs = Me.PORecSubfrm.Form.RecordsetClone
With rs
If Not .BOF And Not .EOF Then
.MoveLast
.MoveFirst
If .Updatable Then
.Edit
!QtyReceived = QtyOrdered
.Update
End If
End If
.Close
End With
Set rs = Nothing
End Sub
Where am I going wrong?? The code in both of these scenarios gets hung up at the !QtyReceived = QtyOrdered line.