RitaMoloney
Registered User.
- Local time
- Yesterday, 21:47
- Joined
- May 6, 2004
- Messages
- 50
Hi,
I have a continuous subform, where records are saved too. The number of parts used are entered in each row and then the new UnitsInStock value is calculated accordingly.
UnitsOnHand:[NumberUsed]-[UnitsInStock].
This UnitsOnHand becomes the new UnitsInStock value which is working fine so far.
I want to put a Delete Button on the subform so that if the user needs to delete a record/row they can and I need the UnitsInStock value to be recalculated.
I have a calculated text box called DeleteRow with the following expression;
=[NumberUsed]+[UnitsInStock]
When a row is deleted I need the value in DeleteRow to be saved to UnitsInStock
I am using the following code is in the event procedure of the Delete Button;
Private Sub cmdDeleteRecord_Click()
On Error GoTo Err_cmdDeleteRecord_Click
If MsgBox("Are you sure you want to delete the '" & Me.PartName & "' record?", vbQuestion + vbOKCancel, "Delete Current Record") = vbCancel Then
'user clicked Cancel
MsgBox "Delete action aborted!"
Exit Sub
Else 'user clicked OK
UnitsInStock.Value = DeleteRow.Value
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_cmdDeleteRecord_Click:
Exit Sub
Err_cmdDeleteRecord_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteRecord_Click
End If
End Sub
This will delete a row but in is not saving the calculation to UnitsInStock. Could someone please help me out with this as I am not very good with vb.
Thanks in advance,
Rita
I have a continuous subform, where records are saved too. The number of parts used are entered in each row and then the new UnitsInStock value is calculated accordingly.
UnitsOnHand:[NumberUsed]-[UnitsInStock].
This UnitsOnHand becomes the new UnitsInStock value which is working fine so far.
I want to put a Delete Button on the subform so that if the user needs to delete a record/row they can and I need the UnitsInStock value to be recalculated.
I have a calculated text box called DeleteRow with the following expression;
=[NumberUsed]+[UnitsInStock]
When a row is deleted I need the value in DeleteRow to be saved to UnitsInStock
I am using the following code is in the event procedure of the Delete Button;
Private Sub cmdDeleteRecord_Click()
On Error GoTo Err_cmdDeleteRecord_Click
If MsgBox("Are you sure you want to delete the '" & Me.PartName & "' record?", vbQuestion + vbOKCancel, "Delete Current Record") = vbCancel Then
'user clicked Cancel
MsgBox "Delete action aborted!"
Exit Sub
Else 'user clicked OK
UnitsInStock.Value = DeleteRow.Value
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_cmdDeleteRecord_Click:
Exit Sub
Err_cmdDeleteRecord_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteRecord_Click
End If
End Sub
This will delete a row but in is not saving the calculation to UnitsInStock. Could someone please help me out with this as I am not very good with vb.
Thanks in advance,
Rita