Results 1 to 4 of 4
  1. #1
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39

    Code Close Form

    I have a form that opens from a button on a sub-form of the Switchboard.



    When I close the form, it returns to the page on the Switchboard from where it was activated by this code -

    [Private Sub b_ClsCPFrm_Click()
    DoCmd.Close acForm, Me.Form.Name
    End Sub]

    I want the form to close and return to the main (first/default) page of the Switchboard.

    What do I need to add to the code above to make this happen?

    Many thanks, mortonsafari

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Maybe this?

    Code:
    Private Sub b_ClsCPFrm_Click()
        docmd.close acform, "frmSwitchBoard"
        docmd.openform "frmSwitchBoard"
        DoCmd.Close acForm, Me.Form.Name
    End Sub

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Might work just fine, but if this "page" is a page on a tab control, there's an opportunity for the OP to learn something about tab controls and their pages instead of a work around.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    Thanks for advice.
    I swapped Command lines two and three around so that form closes and Switchboard open.
    Appreciate your help. . . . mortonsafari

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

Similar Threads

  1. Replies: 5
    Last Post: 10-13-2015, 02:53 PM
  2. Close form with code
    By CoachPoffy in forum Programming
    Replies: 6
    Last Post: 01-07-2015, 08:38 AM
  3. Replies: 4
    Last Post: 01-31-2014, 11:47 AM
  4. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  5. close form code not releasing recordsource..
    By dmeehanjr in forum Forms
    Replies: 1
    Last Post: 08-12-2010, 05:42 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