Results 1 to 7 of 7
  1. #1
    M4ttyC88 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    4

    Close Form A After Opening Form B

    Hi All

    I'm currently having a problem with a macro where I can't get a form to close on cue.

    I have a value on Form A which the Macro uses to filter results on Form B so I can't close Form A before opening Form B.

    I can't do anything with the database other than use Form B. Once I have finished with Form B, Form A then closes.

    Here is the code i'm using, (I have tried the Close function everywhere in this code segment)


    ACTION ARGUMENTS
    Open Form Contact Details, Form, , ="[ID]=" & [Screen].[ActiveControl], , Dialog
    Close Form, , Yes
    OnError Next,
    ReQuery =[Screen].[ActiveControl].[Name]

    Any help would be greatly appreciated as it's currently driving me nuts.

    Thanks in Advance

    Matt

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    When you use the Dialog argument, code/macro execution halts until that form is either closed or hidden.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    M4ttyC88 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    4

    Thanks!!

    Thanks PBALDY that worked for me.

    Only thing I can't seem to get around is I have to specify a Form to stop it closing all forms. The only thing I can think of to get round this is to somehow hide the form and only close active forms?? I'd like to avoid VBA if possible as I may not always be with this comapny to fix it if things go wrong.

    I have given you recognition on my other posting for this
    http://www.utteraccess.com/forum/Clo...6#entry2196856

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I don't use macros, but can't you specify the form to be closed? Looking at my version, there's an "Object Name" argument.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    M4ttyC88 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    4
    I can specifiy the form to be closed, Close Form, Asset Details ... Only problems is i have more than one Form where i want to do this same action going to the same form. Basically when you click on the owner in the either the Assets or Software forms it takes you to the the contacts form for that particular owner.

    I can get round it by creating a macro for the each of the individual original forms (Asset or Software Form) but this could get quite busy if my boss decides he wants the same thing on reports and in any future forms.
    Last edited by M4ttyC88; 01-10-2012 at 01:07 AM.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Sorry I misread the question and lost track of the thread. Did you get this sorted out?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    M4ttyC88 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    4
    In the end I had to create 2 macro's for 2 Form A's

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

Similar Threads

  1. Replies: 2
    Last Post: 07-26-2011, 08:26 AM
  2. Replies: 2
    Last Post: 06-20-2011, 03:10 PM
  3. Open Form and Close Previous Form
    By gerrymouse1 in forum Forms
    Replies: 3
    Last Post: 04-19-2011, 05:42 AM
  4. Replies: 5
    Last Post: 03-11-2011, 10:29 PM
  5. Replies: 1
    Last Post: 11-09-2010, 03:02 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