Solved: I had an piece of code that entered a record when the form Onload that I didn't need. Thanks for all your help everything works great now.
Code:
Code:
Private Sub IDnum_BeforeUpdate(Cancel As Integer)
' Displays a message box with the yes and no options.
NewPeerRecord = MsgBox("Are you sure you want to create a new record?", vbYesNo + vbQuestion, "New Record?")
If NewPeerRecord = vbNo Then
NewPeerRecord = MsgBox("New Peer Record has been canceled!", vbOKOnly + vbInformation, "Record Canceled")
Cancel = True
Me.Undo
ElseIf NewPeerRecord = vbYes Then
Dim rs As DAO.Recordset
Dim strIDnum As String
Set rs = CurrentDb.OpenRecordset("SELECT IDnum FROM Practitioner")
'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst 'Unnecessary in this case, but still a good habit
Do Until rs.EOF = True
If IsNull(strIDnum) Then
DoCmd.Save acForm, "Practitioner"
Me.Last.SetFocus
End If
If rs!IDnum = Me.IDnum.Value Then
Cancel = True
Me.Undo
End If
'Move to the next record.
rs.MoveNext
Loop
End If
rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
If Cancel Then
NewPeerRecord = MsgBox("There is already a peer review record with that" & vbNewLine & "IDNumber. You can select that number from the" & vbNewLine & "ID Number dropdown list above.", vbOKOnly + vbExclamation, "Record Exists!")
End If
End If
End Sub