Open form to new record

NWGal
2StarLounger
Posts: 198
Joined: 21 Aug 2011, 02:32

Open form to new record

Post by NWGal »

I have an unbound form with buttons on it for performing different operation. I have an unbound combo box and a button that opens my main contact form to the record matching the choice in the combo box. Works great. Now I want a "new record" button that opens the same contact form, but to a new (blank) record.
I need the vba code for the onclick event of this command button.
Thanks

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Open form to new record

Post by HansV »

Try this:

Code: Select all

Private Sub cmdNewRecord_Click()
    DoCmd.OpenForm FormName:="frmContacts", DataMode:=acFormAdd
End Sub
where frmContacts is the form to open.
Best wishes,
Hans

NWGal
2StarLounger
Posts: 198
Joined: 21 Aug 2011, 02:32

Re: Open form to new record

Post by NWGal »

HansV wrote:Try this:

Code: Select all

Private Sub cmdNewRecord_Click()
    DoCmd.OpenForm FormName:="frmContacts", DataMode:=acFormAdd
End Sub
where frmContacts is the form to open.
Yup! That did the trick. Thanks