Results 1 to 3 of 3
  1. #1
    pwmichael is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    1

    Update Calculation When Opening Form

    New to Access and need some help (I apologize if I'm using the wrong terms). I have a main form (Security) that contains a subform (LotsSubForm). In the Securities form I have a field named "Basis" that is the sum of a field (basis) in the subform.


    I am able to get the "Basis" field to populate when leaving the subform with the On Exit Exit Procedure

    Private Sub LotsSubForm_Exit(Cancel As Integer) Me.calcbasis = Me.LotsSubForm!newbasis
    End Sub

    When I first open the Security form "Basis" is blank and I would like to have it populate with the sum of the "Basis" field in the subform, as it does when I exit the subform. I have tried using the same syntax in the "Security" form with the Event Procedures On Load and On Open but it is still blank.



    Any Ideas on what I am doing wrong?

    Thanks.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    On open would be no good, but I would have thought On Load would have worked as subforms load first

    Perhaps the OnActivate event?, or even the OnCurrent would be better, as it will update when you change main record?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    The reference doesn't look right for those events but not sure as different words/names are being used to describe the same things?
    Try syntax of
    Code:
    Forms!MainFormName!SubformControlName.Form.ControlName
    SubformControlName is the name of the control that holds the subform. Don't change the red parts.
    If you're storing this calculation, generally that is a no-no.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update table with form calculation?
    By tpann in forum Access
    Replies: 1
    Last Post: 02-11-2020, 08:37 PM
  2. Replies: 8
    Last Post: 03-20-2017, 07:22 PM
  3. Update query with calculation trouble
    By NightWalker in forum Queries
    Replies: 10
    Last Post: 12-13-2016, 06:17 PM
  4. Replies: 10
    Last Post: 06-10-2014, 09:03 AM
  5. Replies: 2
    Last Post: 03-03-2010, 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums