Results 1 to 5 of 5
  1. #1
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43

    Calcuations

    I have three fields in a subform that I need to use in a calculation on the main form. :
    NG_Cast
    OK_Cast
    Repaired_Cast



    The subform and the main form are linked via a field called Issue_Number. This is also the primary key.

    What I need is a text box that adds together these fields on the main form using the Issue_Number field. Currently when someone starts a new entry the issue number is auto populated with a number and the subform uses that number to tie together the data entered there with the main form.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    In the main form, the text box formula= BG+ok+repaired+txtBoxSub
    txtBoxSub box is unbound, but is filled via the subForm.
    in the subForm,use the OnCurrent event to fill the txtBoxSub to the value.
    Code:
    sub form_onCurrent()
      Forms!mainForm!txtBoxSub = nz(me.field)
    end sub
    When user clicks a different record in the sub form,it updates the master form calculated field.

  3. #3
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    So what i have now is:

    =[NG_Cast]+[OK_Cast]+[Repaired_Cast]+[Text475]

    This is the control source for the text box. The name of the text box is Text475

    In the on current for the subform i have

    Private Sub Form_Current() Forms!frm_p1_sorts!Text475 = Nz(Me.Text475)
    End Sub:

    When try to use the form i am getting an error from the on current event.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Text475 is the name of the txtbox on the MAIN form.
    the text box on the SUB form may be a different name.

    Forms!frm_p1_sorts!Text475 = Nz(me.SUBFORMTEXTBOXNAME)

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    See this site for referring to controls on a subform from the main form

    Refer to Form and Subform properties and controls

    http://access.mvps.org/access/forms/frm0031.htm

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

Similar Threads

  1. Counts & Calcuations in Select Query
    By BLD21 in forum Queries
    Replies: 4
    Last Post: 04-08-2011, 11:29 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