Results 1 to 4 of 4
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    DoCmd.Close

    when using a command button to close a form, i have seen both:

    ... DoCmd.Close
    and


    ... DoCmd.Close acForm, Me.Name

    ? is there an advantage / reason for... one over the other?

    as always, with appreciation in advance,
    m.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Without specifying an object you might close the active object which can cause an unexpected result - what you expect to be the active object might not be. Can also be problematic when trouble shooting code as the code window may be active. IMO, best to be explicit and avoid surprises.

    EDIT - I realize that often when code behind a form is executing, that form is likely the active object. However, sometimes such calls are passed to public subs or functions, and sometimes code can branch off and make some other object the active object (e.g. you want to get the Text property from another form so you have to set focus to that control, which by default, makes some other form the active object). As long as you understand the implications, you should be fine. I'm just saying in my initial post that you can't go wrong by being explicit about it.
    Last edited by Micron; 02-13-2021 at 11:59 AM. Reason: spelin and gramur
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    perfect... thnx!

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    You probably didn't see my edit, so here's a followup to trigger an email.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Query ask for Parameter on DoCMD.Close
    By amcintosh in forum Database Design
    Replies: 4
    Last Post: 12-21-2020, 03:48 AM
  2. DoCMD.Close not always working
    By Canadiangal in forum Programming
    Replies: 14
    Last Post: 10-21-2020, 07:08 PM
  3. DoCmd Close Query Not Working
    By bfont in forum Programming
    Replies: 2
    Last Post: 04-16-2020, 03:25 PM
  4. DoCmd.Close Not Working
    By kdbailey in forum Access
    Replies: 6
    Last Post: 12-11-2013, 07:35 PM
  5. DoCmd.Close OpenArgs NOT WORKING
    By clchris_80 in forum Access
    Replies: 1
    Last Post: 01-19-2013, 09:07 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