Greetings all:
I have a field on a subform where I enter an amount. I need assistance in figuring out how to update a field on the main form based on my entry on the subform. I will need to + or - the amount on the main form based on the amount in the subform. I am using this, to no avail, in the AfterUpdate Event of the subform field:
Private Sub Receipt_Adjustment_AfterUpdate()
Forms!frmInventoryNew!OnHand = Forms!frmInventoryNew!OnHand + Forms!frmInventoryNew!frmAdjustments!Receipt_Adjustment
End Sub
Any and all assistance is greatly appreciated. TIA
Bill
Update field on Main Form
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
Re: Update field on Main Form
After further checking, this seems to work after all. Thanks anyway.
-
- Administrator
- Posts: 78378
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Update field on Main Form
Glad it's working. You could simplify the code slightly:
Parent, when used in code behind the subform, refers to the main form. The advantage is that you don't have to specify the name of the main form or subform, so you won't have to edit the code if you rename either.
Code: Select all
Private Sub Receipt_Adjustment_AfterUpdate()
Me.Parent!OnHand = Me.Parent!OnHand + Me!Receipt_Adjustment
End Sub
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
Re: Update field on Main Form
Thanks for the tip, Hans. I'll give it a try.