Results 1 to 3 of 3
  1. #1
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58

    closing forms if they are currently hidden

    When a certain form is opened I have VBA opening another form and hiding it.
    When I close visible form I get an error message stating it can't find the hidden form. My VBA is trying to determine whether that hidden form is currently open and hidden but does not seem to work.
    Here is a sample of that code:
    ================================================== ==================
    Private Sub Form_Close()


    ' Closes the Delivery Board form if it is currently open and hidden when the Shipping Log form is closed

    If Forms![frmDeliveryBoard].Visible = False Then
    DoCmd.Close acForm, "frmDeliveryBoard"
    Else
    DoCmd.Close acForm, "frmShippingInfo"
    End If


    End Sub
    ================================================== ====================

    Appreciate the help in getting this to work. Thanks.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe try the IsLoaded property.

    Code:
    '================================================== ==================
    Private Sub Form_Close()
    ' Closes the Delivery Board form if it is currently open and hidden when the Shipping Log form is closed
    
    If CurrentProject.AllForms("frmDeliveryBoard").IsLoaded = True Then
       DoCmd.Close acForm, "frmDeliveryBoard"
    Else
       DoCmd.Close acForm, "frmShippingInfo"
    End If
    
    
    End Sub
    '================================================== ====================

  3. #3
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58
    That seemed to do it. Many Thanks!!

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

Similar Threads

  1. Replies: 5
    Last Post: 01-27-2016, 07:05 AM
  2. how to demystify hidden objects on forms
    By kattatonic1 in forum Database Design
    Replies: 4
    Last Post: 07-14-2014, 09:13 AM
  3. Code for closing all opened forms
    By gstylianou in forum Access
    Replies: 9
    Last Post: 06-30-2014, 01:35 AM
  4. Closing Datasheet Forms Within Each Other
    By jfriedm in forum Access
    Replies: 11
    Last Post: 11-23-2012, 03:31 PM
  5. Replies: 9
    Last Post: 04-20-2012, 08:13 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