Access World Forums

Access World Forums (
-   Forms (
-   -   Problem with button coding (

chappy68 08-17-2011 11:13 PM

Problem with button coding
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
If (MacroError <> 0) Then
MsgBox MacroError.Description, vbOKOnly, ""
End If

Exit Sub
MsgBox Error$
Resume butSaveNewOnNewClient_Click_Exit
End Sub

MarkK 08-18-2011 09:45 AM

Your last enabled error handler is this:

On Error Resume Next
This supresses all errors from being raised.

All times are GMT -8. The time now is 04:32 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World