Results 1 to 2 of 2
2004-08-04, 13:08 #1
- Join Date
- Jan 2001
- 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
MsgBox "You must select a record to continue."
Resume lstSearchResult_Exit 'Open Result_frm based on the Result_ID from lstSearchResult listbox
2004-08-04, 13:33 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 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.