Make sure your form with a listbox has a Cancel button and has the following
code in the Click event:
DoCmd.Close
You don't need any other buttons on this form!
Put the following code in the AfterUpdate event of the listbox:
Me.Visible = False
Put the following code in the Click event of the first form:
DoCmd.OpenForm "NameOfListboxForm",,,,,acDialog
If IsLoaded("NameOfListboxForm") Then
Dim Rst As DAO.Recordset
Rst.FindFirst "[PrimaryKeyOfFirstForm] = " &
Forms!NameOfListBoxForm!NameOfListBox
DoCmd.Close acForm, "NameOfListboxForm"
End If
Note 1 -- You can find the IsLoaded Function in Northwind's standard modules
Note 2 -- The above FindFirst statement is for a numeric PK, use the
following for a string PK:
Rst.FindFirst "[PrimaryKeyOfFirstForm] = '" &
Forms!NameOfListBoxForm!NameOfListBox & "'"
Everything is done by one click of the button on the first form!!