Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing a form from another form (Access 2000 SR 3)

    I use the code on the double click event of a list box (lstSearchResult) on a form called Search_frm. When the user dbl clicks on the field it opens a form called Results_frm using the Result_ id to show the matching record of the selected Result_id on Search_frm. I would like to modify this so that the Search_frm does not remain open under the Results_frm. Is there a way to close the Search_frm once the Results_frm is open? Thanks...


    Private Sub lstSearchResult_DblClick(Cancel As Integer)
    On Error GoTo lstSearchResult_Err
    DoCmd.OpenForm "Results_frm", , , "[Result_ID] = " & Me.lstSearchResult, , acNormal
    DoCmd.Maximize
    lstSearchResult_Exit:
    Exit Sub
    lstSearchResult_Err:
    MsgBox "You must select a record to continue."
    Resume lstSearchResult_Exit 'Open Result_frm based on the Result_ID from lstSearchResult listbox
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing a form from another form (Access 2000 SR 3)

    Immediately above Exit Sub, insert a line

    DoCmd.Close acForm, Me.Name, acSaveNo

    This will close the Search_frm unconditionally. If you want to close it only if the other form was opened successfully, but not if an error occurred, place the line immediately above the lstSearchResult_Exit: label.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •