Go to new record

User avatar
Michael Abrams
4StarLounger
Posts: 573
Joined: 10 Feb 2010, 17:32

Go to new record

Post by Michael Abrams »

Simple button, Add new Record.

Code: Select all

Private Sub cmdAddNewRec_Click()

If MsgBox("Did you click the SAVE BUTTON?", _
                vbQuestion + vbYesNo, "CONTINUE?") = vbNo Then
  
               DoCmd.CancelEvent        
Else
       
    DoCmd.GoToRecord , , acNewRec
        
    Me.cboHP.SetFocus
                        
End If


End Sub
If I click no, I have to click the Save button.

If I click Yes, is stays on the current record and sets focus to the cboHP field.

It does not go to a new record. Is there a form property I should look at? It is set to Data Entry = No.

Thank you,
Michael

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

Re: Go to new record

Post by HansV »

I created a small form to test your code. After clicking Yes the form did move to a new record, so the code is OK.
Have you perhaps set AllowAdditions to No?
Best wishes,
Hans