Results 1 to 7 of 7

Form error on closing form: "The object [FormName] isn't open"

  1. #1
    skydivetom is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    261

    Form error on closing form: "The object [FormName] isn't open"


    Experts:

    I need some assistance with resolving an error upon closing a form.
    Attached database included the following objects:
    - 2 tables
    - 1 query
    - 2 forms
    - 1 macro

    Current process:
    - User open the form "F05_OrganizationList" (which includes five N-Codes/offices)
    - For any of the five offices, user clicks on the "Open" hyperlink (which brings up "F05_Organization")

    What I need some help with:
    - When bringing up form "F05_Organization" and then closing it, an error occurs.
    - Error indicates "The object 'F05_Organization' isn't open'.

    I believe I validated many (if not all) of event properties in F05_OrganizationList. Apparently, however, there must be another property which may reference another form (I copied the org list form from another process).

    My question: How do I get rid of the error when closing F05_Organization (when opened through F05_OrganizationList)?

    Thank you,
    EEH
    Attached Files Attached Files

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    358
    In your embedded macro you are opening the form in dialog mode which then halts the code in your embedded macro. When you close that dialog form the code continues to run and errors at the search part of it.

  3. #3
    mike60smart is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    149
    Hi

    See if the attached modified db is a better method of selecting an Organisation.
    Attached Files Attached Files

  4. #4
    skydivetom is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    261
    moke123 - thank you for the feedback. I've copied the search list form from another form (e.g., on staff members and billets). Both of those two forms work w/o issue.

    mike60smart - thank you for suggestion. Unfortunately, that process won't work for me. That is, in the actual search form, I have additional fields beyond the two fields. Different users utilize different search criteria so I need to continue using the search form.

    As mentioned, I was able to tweak this when copying the same concept for staff members and turning it into the billets form. Please find attached version w/ a working concept (for billets). Why is this one working but it doesn't work for the organization? Any thought on what might be different between the originally posted database and the latest one? Still need to resolve the search form for the organization.

    Thanks,
    EEH
    Attached Files Attached Files

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    358
    This is a stark reminder of why I hate embedded macros.
    I converted to vba and cleaned up but not sure I understand what you want to happen.

    I think you have the wrong form name in the docmd.searchforrecord line. shouldn't it be the list form?

    try using this code in the "txtOpen" click event

    Code:
    Private Sub txtOpen_Click()
    
    
        If Me.Dirty Then Me.Dirty = False   '< Is the form ever dirty? you may not need this line
    
    
        DoCmd.OpenForm "F05_Organization", acNormal, "", "[OrganizationIDpk]=" & Nz(OrganizationIDpk, 0), , acDialog
    
    'the code is paused here while the F05_Organization form is open
    'When the form is closed the focus returns to the list form
    'if the tempvar is supposed to get its value from F05_Organization then the below is wrong.
    
        If (Not IsNull(ID)) Then
        
            TempVars.Add "CurrentID", OrganizationIDpk.Value
            
        ElseIf (IsNull(ID)) Then
        
            TempVars.Add "CurrentID", Nz(DMax("[OrganizationIDpk]", Form.RecordSource), 0)
            
        End If
    
    
        Me.Requery  ' I would do this in the onclose event of the other form.  
    
    
        DoCmd.SearchForRecord acForm, "F05_OrganizationList", acFirst, "[OrganizationIDpk]=" & TempVars!CurrentID
    
    
        TempVars.Remove "CurrentID"
    
    
    End Sub

  6. #6
    skydivetom is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    261
    moke123 -- I hear you about the macros... anyhow.

    You were absolutely right... I changed the reference to the list form and it now works like a charm. Thousand thanks for helping to identify the incorrect form property. I very much appreciate your help!!!

    Cheers,
    Tom

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    358

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

Similar Threads

  1. Replies: 2
    Last Post: 02-06-2019, 01:24 PM
  2. Replies: 3
    Last Post: 07-12-2017, 04:29 PM
  3. Replies: 17
    Last Post: 04-28-2017, 09:18 PM
  4. Replies: 3
    Last Post: 02-06-2015, 03:22 PM
  5. Replies: 3
    Last Post: 07-19-2014, 01:15 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
  •  
Tech Forums: Microsoft Office Forums