Problem with button coding (1 Viewer)

chappy68

Registered User.
Local time
Yesterday, 23:34
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

bit cruncher
Local time
Yesterday, 23:34
Joined
Mar 17, 2004
Messages
8,180
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

Top Bottom