You can't go to a new record when you are on a new record. Add error handling.
Code:
Private Sub CmdNewRec_Click()
On Error GoTo ErrProc
DoCmd.GoToRecord , , acNewRec
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 2105 'already on new record
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub
You can't go to a new record when you are on a new record. Add error handling.
Code:
Private Sub CmdNewRec_Click()
On Error GoTo ErrProc
DoCmd.GoToRecord , , acNewRec
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 2105 'already on new record
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub
I explained that. The BeforeInsert event runs before any data is placed in form controls so since you are using the ID in your test, the ID isn't available until AFTER the BeforeInsert event finishes. If you didn't need ID, then you could use the BeforeInsert event.