We help IT Professionals succeed at work.

how to close form after inserting new records

kg6lfz
kg6lfz asked
on
I have a Form1 that user can input ship_id and ship_date.  Upon the clicking on "OK", those inputs were inserted into Table1.  This works fine.  But the Form1 stays open.  How can I close the Form1 when users click on "OK" and records are inserted at the same time?

Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click

    DoCmd.GoToRecord , , acNewRec

Exit_cmdAddNew_Click:
    Exit Sub

Err_cmdAddNew_Click:
   MsgBox Err.Description
   Resume Exit_cmdAddNew_Click

End Sub
Comment
Watch Question

Try DoCmd.Close
Private Sub cmdAddNew_Click()
 On Error GoTo Err_cmdAddNew_Click

     DoCmd.GoToRecord , , acNewRec

 Exit_cmdAddNew_Click:
DoCmd.Close
     Exit Sub

 Err_cmdAddNew_Click:
    MsgBox Err.Description
    Resume Exit_cmdAddNew_Click

 End Sub 

Open in new window

Flyster