Results 1 to 4 of 4
  1. #1
    Jester0001 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Indiana
    Posts
    69

    VBA Referencing Subform Control Error 2465

    I have a Navigation Form with a subform. Here is the basic layout:

    Navigation Form: [Home Page] <<<< I know I shouldn't use a space in the name, but it's only one form

    Subform: [frmInsertResults]

    Control: CheckSCC <<<< This is a checkbox control

    Here is the code I am using in the immediate window, and as the msgbox:

    Immediate Window Code:

    Code:
    ? Forms![Home Page]!frmInsertResults.Form!CheckSCC
    VBA Code:

    Code:
    MsgBox Forms![Home Page]!frmInsertResults.Form!CheckSCC
    It returns a run-time error '2465': Microsoft Access can't find the field 'frmInsertResults' referred to in your expression.

    The main form and subform are both open in form view (even tried in layout view). I've checked the spelling of the form, subform, and control to make sure they are correct. All I would like to do is to be able to find the current value of the control in the Immediate Window so I can begin writing more code.



    Dumb question, and I've done this successfully a few times today already with a different form and subform. I can't get it to work for me this time.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Try:
    MsgBox Forms![Home Page].frmInsertResults.Form.CheckSCC
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Is [frmInsertResults] the name of the sub-form, or the name of the CONTROL containing that form? It has to be the name of the CONTROL, not the name of the form, so you would use something like:


    ? Forms![Home Page]!controlname.Form!CheckSCC

    HTH

    John

  4. #4
    Jester0001 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Indiana
    Posts
    69
    Bob's suggestion didn't work, but John helped me to arrive at the solution. Apparently, when using a Navigation Form, all of the subforms are shown in the same subform control. This confused me, as the subform control was named after the first subform I added to the Navigation Form.

    Thank you!

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

Similar Threads

  1. Run Time Error 2465
    By jo8701 in forum Programming
    Replies: 1
    Last Post: 02-08-2012, 12:01 PM
  2. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  3. referencing a control
    By looloo in forum Programming
    Replies: 3
    Last Post: 09-23-2011, 07:57 PM
  4. Run Time Error 2465 In Report
    By desk4tbc in forum Programming
    Replies: 9
    Last Post: 09-06-2011, 08:00 PM
  5. Run-Time error '2465'
    By hawkins in forum Access
    Replies: 6
    Last Post: 08-19-2011, 04:07 PM

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