OK I'm having a bit of brain fade b/c I must be missing the obvious here
I'm trying to update a form description based upon totals in the subform header. SumOfQty, SumOfAmt, MinOfFromDate, MaxOfToDate, AvgOfRate in the subform are used to build up a string used in document headers. This built up string is a default value that sometimes needs to be changed by the user (me).
Problem: if i change Qty which then changes sumOfQty then nothing is seen in mainform's header except literals. If then change the Rate which changes avgOfRate then the literals & sumOfqty will be in the header but not the new avgRate. & so on.
I'm using the subForm's AfterUpdate event to pass the changes. & upon each of the relevant subform fields i'm doing a
The modules are small so I'll include relevant parts here.
main form's code....
SUBFORM'S CODE
I'm trying to update a form description based upon totals in the subform header. SumOfQty, SumOfAmt, MinOfFromDate, MaxOfToDate, AvgOfRate in the subform are used to build up a string used in document headers. This built up string is a default value that sometimes needs to be changed by the user (me).
Problem: if i change Qty which then changes sumOfQty then nothing is seen in mainform's header except literals. If then change the Rate which changes avgOfRate then the literals & sumOfqty will be in the header but not the new avgRate. & so on.
I'm using the subForm's AfterUpdate event to pass the changes. & upon each of the relevant subform fields i'm doing a
Code:
DoCmd.RunCommand acCmdSaveRecord
The modules are small so I'll include relevant parts here.
main form's code....
Code:
Option Compare Database
Option Explicit
Private Sub Documents_PayeeID_AfterUpdate()
'....for set up stuff deleted....
Me.SubForm.SetFocus
DoCmd.GoToControl "Index"
End Sub
Private Sub Form_Current()
'...not relevant code...
End Sub
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub UpdateHeader() 'What I'm trying to accomplish... but not called in this module
Me.Header = "Consulting " _
& " from " & Format(Me.SubForm.Form.MinOfFromDate, "Medium Date") _
& " to " & Format(Me.SubForm.Form.MaxOfToDate, "Medium Date") _
& " (" & Format(Me.SubForm.Form.AvgOfRate, "Currency") _
& " x " & Format(Me.SubForm.Form.SumOfQuantity, "#,##0.00") & ")"
End Sub
SUBFORM'S CODE
Code:
Option Compare Database
Option Explicit
Private Sub ToDate_BeforeUpdate(Cancel As Integer)
'...validations deleted...
End Sub
Private Sub Rate_AfterUpdate()
Me.Amount = Me.Rate * Me.Quantity
UpdateDescription
End Sub
Private Sub Quantity_AfterUpdate()
Me.Amount = Me.Rate * Me.Quantity
UpdateDescription
End Sub
Private Sub FromDate_AfterUpdate()
UpdateDescription
End Sub
Private Sub ToDate_AfterUpdate()
UpdateDescription
End Sub
Private Sub Index_AfterUpdate()
Me.Fund = DLookup("[Fund]", "Funds", _
"[Index]=" & Me.Index & " AND [FromDate]<=#" & date _
& "# AND [ToDate]>=#" & date & "#")
UpdateDescription
End Sub
Private Sub UpdateDescription()
DoCmd.RunCommand acCmdSaveRecord
Me.Description = "Consulting" _
& " for " & Trim(Me.Index.Column(1)) & " project" _
& " from " & Format(Me.FromDate, "Medium Date") _
& " to " & Format(Me.ToDate, "Medium Date") _
& " (" & Format(Me.Rate, "Currency") _
& " x " & Format(Me.Quantity, "#,##0.00") & ")"
End Sub
Private Sub Form_AfterUpdate()
Me.Parent.Form.Header = "Consulting " _
& " from " & Format(Me.MinOfFromDate, "Medium Date") _
& " to " & Format(Me.MaxOfToDate, "Medium Date") _
& " (" & Format(Me.AvgOfRate, "Currency") _
& " x " & Format(Me.SumOfQuantity, "#,##0.00") & ")"
End Sub