Results 1 to 13 of 13
  1. #1
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117

    Close linked form with vba

    I have 10 forms which are synchronised. When the main form is open, each of the 9 others can be individually opened using their own command button.
    As each of the "non" main forms is opened, it is a filter of the main form.
    Is there anyway that I can automatically CLOSE any of the "non"main forms when I go back to the main form.
    I have tried deacticate, lost focus, timer etc but nothing works

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Any particular form or *all* of them? The active forms are all listed in the Forms collection.

  3. #3
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Either way - if they all close it wouldn't matter
    As it is access only allows a certain amount to be open at the same time anyway.....

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Did you try DoCmd.Close?

  5. #5
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Click image for larger version. 

Name:	SKMBT_36151209104100_0001.jpg 
Views:	9 
Size:	118.3 KB 
ID:	22975
    In order to help explain what I need, above is a screenshot of what the user sees.
    The main page (called DETAILS) is a tabbed page.
    On the right hand side are 11 command buttons which each open a new page. Each individual page is linked to the DETAILS page through the control NCR No.
    What I would like to happen is that if the user opens any of the right hand pages, then when they have finished, any that are open will automatically close when the main form (DETAILS) is back in focus.
    Is this possible

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Are the forms opened by those 11 command buttons opened in Dialog mode?

  7. #7
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    I am not sure how to answer this.
    All forms have pop up and modal set to NO
    Is that what you need to know ?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    So you do not require the user to complete the form before closing, right?

  9. #9
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    No - the user does not have to enter anything on any of these forms - they are for viewing only.
    There is a duplicate set of the forms whcih are used for data entry purposes and these are opened via another switchboard form

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    So once the user leaves the additional form they are assumed to be done viewing it? What did you put in the various events of that form to try and close it?

  11. #11
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    I looked on several sites and forums and tried DoCmd code on the following events
    Deactivate
    Lost Focus
    On Timer
    none have worked - but that is probably down to inaccurate use of code
    I need to understand whether what I want is dooable and if I am actually going abouit it the right way.
    If I am on the right path I think it is then simply a matter of finding out which event will work best.................

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    See if you can display a MsgBox in those events. Then you'll know if they are firing. The message should say which event they are in.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I believe it would be better for each form to close itself but here's a link to code that would close them all. It is also a terrific site as a reference for darn near anything.
    http://access.mvps.org/access/forms/frm0040.htm

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

Similar Threads

  1. Replies: 2
    Last Post: 01-16-2015, 01:25 PM
  2. Replies: 4
    Last Post: 10-09-2014, 07:09 PM
  3. Replies: 2
    Last Post: 04-15-2014, 10:03 PM
  4. Replies: 4
    Last Post: 01-31-2014, 11:47 AM
  5. Replies: 2
    Last Post: 06-20-2011, 03:10 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