Results 1 to 3 of 3
  1. #1
    RAOtto01 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Location
    Lomita, CA
    Posts
    4

    Exclamation Trouble Closing Form with VBA

    I have a main form (Add_Member_Person_MemberDB) with combo box in header with a query that lists all records (members). When a record is selected a subform in the detail section lists all the records (i.e. events) associated with the selected record (member).

    There is a button in the header of form to "Add new member" which brings up a data entry form (frmNewMember). Both forms are working properly. However when I return to the main form the new record (member) is missing from the combo box in the header.

    If I close the main form and reopen it manually the new record (member) appears as the query is executed. So I added VBA code to close the main form on the frmNewMember form "on load" event:


    DoCmd.Close acForm, "Add_Member_Person_MemberDB". Then I reopen the main form when I exit the data entry form.

    The DoCmd.Close... wasn't working so I tried to execute the command in the Immediate window. The following open form command worked:
    DoCmd.OpenForm "Add_Event_Person_MemberDB"

    ....but the
    DoCmd.Close acForm, "Add_Member_Person_MemberDB"
    does not.

    When I try the same open and close DoCmd commands with the frmNewMember form in the Immediate windows it opens and closes fine.

    Any thoughts or suggestions on what is happening or alternative approaches?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Need to requery the combobox.

    Open the form in dialog mode. This will suspend code execution on the main form until the second form closes.

    DoCmd.OpenForm "Add_Member_Person_MemberDB", , , , , acDialog
    Me.comboboxname.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RAOtto01 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Location
    Lomita, CA
    Posts
    4
    Thanks that did solve the problem. I added Me.comboboxname.Requery to Event = On Focus to Form1.

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

Similar Threads

  1. Closing a form and discarding Changes
    By lowesthertz in forum Modules
    Replies: 3
    Last Post: 03-23-2015, 03:40 PM
  2. Replies: 6
    Last Post: 01-06-2015, 12:37 PM
  3. closing form
    By joshynaresh in forum Access
    Replies: 6
    Last Post: 02-05-2014, 09:06 AM
  4. Replies: 5
    Last Post: 12-22-2011, 01:12 PM
  5. Closing a form through VBA
    By ghostmachine in forum Forms
    Replies: 4
    Last Post: 12-13-2010, 01:57 PM

Tags for this Thread

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