Results 1 to 5 of 5
  1. #1
    Leonel is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    12

    Error 2489 object isn't open.

    Thank you
    I've been reading other threads and info on the web, but can't find a solution, so trying the gurus here.

    I have a form with two sub-forms: FormA (subform control FormA_Subform) contains FormB and FormC (FormB_Subform FormC_Subform).
    Click image for larger version. 

Name:	Forms.jpg 
Views:	18 
Size:	19.2 KB 
ID:	32343

    I want to display a specific record in FormC (DoCmd.SearchForRecord) when I click a record in Form B, but I keep on getting the error I mention in the title.

    After some research, this is where I am:

    I understand I need to place the focus on FormC, from FormB, before I can run DoCmd.SearchForRecord. Done using this code in FormB:



    Me.Parent.SetFocus
    Me.Parent!FormC_Subform.SetFocus

    After this I've written:

    DoCmd.SearchForRecord acDataForm, "FormC", acFirst, "[field]=condition".

    But no luck. I've tried replacing FormC with FormC_Subform, Me.Parent!FormC, and Me.Parent!FormC_Subform, but it keeps on saying the object isn't open.



    Thx for your help.
    Leonel

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    See the attached page for how to reference forms and subforms from other forms
    http://access.mvps.org/access/forms/frm0031.htm

    Hopefully that will assist. It would probabaly help you enormously if you renamed the Sub Form Containers to something obviously different from the the sub form names. e.g. cntSubFormB etc.
    You also seem to be referring to form A as if it is also a sub form? Correct or just me misunderstanding?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Leonel is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    12
    Thank you Minty,

    That page is one of my old favorites. You're correct on FormA as a subform. That's a mistake in the post. It's not named as a subform; it's FormA only.

    lg

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you are in FormB, and you want to set the focus to a control in FormC, you will need something like this:

    FormB.parent!FormC_container.form!FormC_Controlname.setfocus

    You never need to refer to FormA explicitly - it is FormB's parent.

    The important part is FormC_container - it is the name of the subform control (on FormA) that contains FormC.

    Remember, too, that when referring to subforms, you rarely if ever have to use the actual form name - you use the name of the subform container the form is in.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    You can do this without code

    1. add a hidden textbox to formA and call it BLink. In the controlsource put

    =[FormBSubformControlName].[Form].[Condition]

    2. in the formC subform control on formA put field in the linkchild property and BLink in the linkmaster property

    you description is not clear about field and control names so change names to suit

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

Similar Threads

  1. Replies: 2
    Last Post: 07-20-2017, 07:20 AM
  2. Replies: 3
    Last Post: 07-12-2017, 04:29 PM
  3. Run-time error 2489
    By dhicks in forum Forms
    Replies: 11
    Last Post: 07-05-2017, 01:34 PM
  4. Replies: 13
    Last Post: 04-21-2016, 03:33 AM
  5. Replies: 1
    Last Post: 11-18-2014, 12:35 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