Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Total From Multiple Subforms (Access 2002)

    I'm trying to add values from to subforms; the text boxes are in the subforms footers. When I used the wizard I can't see the fields that are on my two subforms footers. I was using the following Code =(Nz(Forms!Subfrm1!text001)+Nz(Forms!SubFrm2!text0 02)); but the text box displays Error#.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Total From Multiple Subforms (Access 2002)

    Try removing both occurrences of Forms! so that you get

    =Nz(Subfrm1!text001)+Nz(SubFrm2!text002)

    When you are on the main form, you can refer to a control on a subform as SubFormName!ControlName where SubFormName must be the name that the subform has as a control on the main form. This is not necessarily the same as the name of the subform in the database window.

    You can't use Forms! because the Forms collection contains all open forms. A subform is not "open", it is only a part of the main form.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Total From Multiple Subforms (Access 2002)

    Hans;
    Thank You very much; worked perfectly. One question; why does Access treat the "." and "!" differently. I have used the period in other statements, for example when I preview a report with only the records displayed on the form the criteria will be "[Forms].[MainFrm].[Field1]"; however "[Forms]![MainFrm]![Field1] will also work. Bottom line when do you use a "." and when do you use a "!"?

    Again; thanks very much.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Total From Multiple Subforms (Access 2002)

    The bang ! is used to indicate a member of a collection, and the period . is used to indicate a property or method of an object. Controls are also properties of a form or report, so in many cases where you can use "!", you can also use ".". The following are equivalent:

    Forms!frmMain!txtField
    Forms!frmMain.Controls!txtField
    Forms!frmMain.txtField
    Forms.frmMain!txtField
    Forms.frmMain.Controls!txtField
    Forms.frmMain.txtField

    But not all properties are members of a collection, so you can't always use "!" instead of ".". For example, Forms!frmMain!Visible is not valid, for Visible is a property, not a member of a collection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •