Problem with button coding (1 Viewer)

chappy68

Registered User
Joined
Aug 15, 2011
Messages
76
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
 

MarkK

Super Moderator
Joined
Mar 17, 2004
Messages
7,761
Your last enabled error handler is this:
Code:
On Error Resume Next
This supresses all errors from being raised.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom