I have a seemingly simple issue. I have a field in a form that requires a unique value. It is set in the table properties as index (no duplicates). When I click the button I should get an error message as it tries to save the record. I am not getting the error message and the focus is set on the field ClientName. I have copied the code behind the button below.
What am I missing?
I am using Access 2007 on Windows 7.
'------------------------------------------------------------
' butSaveNewOnNewClient_Click
'
'------------------------------------------------------------
Private Sub butSaveNewOnNewClient_Click()
On Error GoTo butSaveNewOnNewClient_Click_Err
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , "", acNext
ClientName.SetFocus
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
butSaveNewOnNewClient_Click_Exit:
Exit Sub
butSaveNewOnNewClient_Click_Err:
MsgBox Error$
Resume butSaveNewOnNewClient_Click_Exit
End Sub
What am I missing?
I am using Access 2007 on Windows 7.
'------------------------------------------------------------
' butSaveNewOnNewClient_Click
'
'------------------------------------------------------------
Private Sub butSaveNewOnNewClient_Click()
On Error GoTo butSaveNewOnNewClient_Click_Err
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , "", acNext
ClientName.SetFocus
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
butSaveNewOnNewClient_Click_Exit:
Exit Sub
butSaveNewOnNewClient_Click_Err:
MsgBox Error$
Resume butSaveNewOnNewClient_Click_Exit
End Sub