Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Look up a field in a sub-form (Win ME/Access 97)

    I am trying to access a field from an event procedure. I use Forms!MainForm.SubForm!Field. Shouldn't this work? I get an error mesage - Application-defined or object-defined error. Field is in the underlying query for the sub-form, taken from a table. Field is on the sub-form.

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

    Re: Look up a field in a sub-form (Win ME/Access 97)

    Try Forms!MainForm!SubForm!ControlName or Forms!MainForm!SubForm.Form.FieldName.

    Note that SubForm must be the name of the subform control on the main form - this is not necessarily the same as the name of the subform in the database window. If you have a control bound to a field, use the first expression with the name of the control; otherwise, use the second expression with the name of the field.

    For a comprehensive overview of how to refer to controls and properties of subforms, see Forms: Refer to Form and Subform properties and controls on the Access Web.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,328
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Re: Look up a field in a sub-form (Win ME/Access 97)

    The thing to watch out for when trying to reference a control on a subform is that you DON'T use the subform name! You reference it by using the name of the subform control that contains the form. These may be the same, which is the source of some confusion. The correct syntax would be:
    Forms!MainFormName!SubformControlName.Form.Control Name

    The .Form is usually not really needed, but I always include it as I find it makes the code easier to read later on.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Look up a field in a sub-form (Win ME/Access 97)

    Something new everyday. Thank you. Your comments took me eventually to a mispelled sub-form name. It appears that one more problem has been resolved.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Look up a field in a sub-form (Win ME/Access 97)

    Don't worry, there'll always be another problem right around the corner. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Charlotte

Posting Permissions

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