Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Access can't find a sub-form

    I have a Form that includes a Sub-Form. I want to reference one of the fields within the RecordSource of the Sub-Form. Within the code-sheet of the Form, a Public Function is called via a right-click popup menu. A snippet screenshot (below) of the "open" Sub-Form is shown with the record-selector highlighted on the record of interest.



    Click image for larger version. 

Name:	000.jpg 
Views:	7 
Size:	68.8 KB 
ID:	37708

    The following code produced the error shown above: (Note: "FamilyDetailsSubform" is the name of the Sub-Form, NOT the container control.)

    Code:
    Public Function DelPseudoMbr()
    Dim lngFormRec As Long
    
    lngFormRec = Forms!FamilyDetailsSubform.Form!RegistryID
    
    Debug.Print lngFormRec
    End Function
    The Sub-Form is obviously Open so that's not the issue. While query/table field "RegistryID" is not bound within the Sub-Form, I don't think Access got that far anyway so I don't believe that's an issue.
    Am I missing something in the syntax of the failing assignment statement?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You need to include the main form in the reference:

    http://theaccessweb.com/forms/frm0031.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Forms!FamilyDetails!FamilyDetailsSubform.Form!Regi stryID (I bookmarked your reference. Surprised it didn't pop up when I Googled the issue before posting.)

    BINGO!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I was going to yank your chain but figured all the snow had gone to your head.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    How embarrassing! The genesis of the form and its module is mid-Office97, my very early days in Access to say the least. However, after applying your fix and progressing to other items of concern in the module I found another statement from yesteryear that was coded correctly and has been executing successfully for years. See, I told you I CRS!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I battle that disease myself.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 04-16-2018, 09:15 PM
  2. microsoft access cant find the Form"FRM_LOGIN
    By benjfabian in forum Access
    Replies: 2
    Last Post: 11-09-2016, 05:39 AM
  3. Replies: 13
    Last Post: 07-16-2015, 03:58 AM
  4. Replies: 4
    Last Post: 06-25-2014, 01:44 PM
  5. Replies: 1
    Last Post: 03-05-2014, 07:55 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