Subform problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff

    Subform problem

    I have a form with a subform. The latter contains a calculated field,
    [TotCost], derived from a query. In the footer of this subform is an
    unbound text box [FootSum] whose control source = SUM([TotCost]) . works
    fine



    I want to save the value in [FootSum] into a variable in the main form
    called [TotCost]. This is bound to Tbl_Products



    Every time I make a new entry in the subform I want to see [TotCost] updated
    in the main form to reflect the new price calculated in the subform.
    Whenever I make a new entry in the subform the total is correct but it does
    not include the last value entered. Why?





    Private Sub Form_AfterInser t()

    Forms![frmMain]![TotCost] = [FootSum]

    Me.Refresh



    End Sub



    Help would be greatly appreciated.





    Many thanks

    Geoff





  • inkman04

    #2
    Re: Subform problem

    Perhaps what you could try is to save the record
    in the afterupdate of the control that your inputting
    your data. I use this technique quite a bit.

    The reason for the total not showing on the main
    form is due to the record in the subform not
    being saved.

    Place following code into the Afterupdate
    property of the field in the subform:

    DoCmd.RunComman d accmdSaveRecord

    Hopefully, this should do the trick.

    Regards

    Comment

    • inkman04

      #3
      Re: Subform problem

      Sorry, forgot one thing. I don't believe the
      line of code your using, Me.Refresh is needed.

      Regards

      Comment

      Working...