Results 1 to 3 of 3
  1. #1
    RedGoneWILD is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    105

    check if all objects are closed (forms & reports)

    what is the vba code to check if all objects are closed?

    i want a form to open only if all other objects are closed. so i might have 5 things open, but when i close that very last one, i need the code to run to open a specific form

    any help appreciated

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    I used this trick on some healthcare software that I did. write one function. You can write a UDF to check if it's loaded, or you can use the built in property of the CurrentProject object. on every object that is relevant in the on close event, put something like:
    Code:
    =CheckIfLastOpen()
    then as a function, loop the opens and check for a count > 1, e.g.-
    Code:
    dim i as integer, counter as integer
    
    for i = 0 to application.forms.count - 1
         if currentproject.allforms(0).isloaded=true then
              counter = counter + 1
         end if
    next frm
    
    if counter > 1 then
        'THIS IS NOT THE LAST OBJECT OPEN!
    end if
    you'll have to do it for reports and forms both, but that's the idea that I came up with when I did it. Kudos to those who find a faster way!

  3. #3
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    I do the same thing as Adam suggested above.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-06-2010, 09:29 AM
  2. Queries, Forms, Reports..
    By groundhog in forum Access
    Replies: 3
    Last Post: 07-07-2010, 12:30 PM
  3. Forms and Reports
    By nacho in forum Forms
    Replies: 3
    Last Post: 04-17-2010, 01:06 AM
  4. Emailing forms or reports
    By dcecil in forum Reports
    Replies: 6
    Last Post: 12-16-2009, 07:57 AM
  5. Replies: 7
    Last Post: 11-16-2009, 11:56 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