> Access 2000. I cant seem to trap an error on my form. The error is:
> "Microsoft Access was unable to append all the data to the table"
[quoted text clipped - 9 lines]
> Me.Undo
> End If

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
The error statement is: "Microsoft Access was unable to append all the data
to the table. The contents of fields in 0 records were deleted, and 12
records were lost due to key violations etc." Here is the on error event
of my form: This is all I have..
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Err.Number = 10014 Then
Response = acDataErrContinue
MsgBox "These samples may have already been entered in the database.
Select another disk or click yes to continue"
Me.Undo
End If
End Sub
>> Access 2000. I cant seem to trap an error on my form. The error is:
>> "Microsoft Access was unable to append all the data to the table"
[quoted text clipped - 12 lines]
> Would you mind posting the rest of the procedure? You don't show the
> "On Error" statement, nor the statement label for the error-handler.
Dirk Goldgar - 26 Oct 2005 20:38 GMT
> The error statement is: "Microsoft Access was unable to append all
> the data to the table. The contents of fields in 0 records were
[quoted text clipped - 8 lines]
> End If
> End Sub
If you're going to use the form's Error event, you need to interrogate
the DataErr argument that is passed to the event procedure:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 10014 Then
Response = acDataErrContinue
MsgBox _
"These samples may have already been entered " & _
"in the database. Select another disk or " & _
"click yes to continue"
Me.Undo
End If
End Sub
But it would be better to trap the error in the procedure that raises
it. So if you have a procedure that currently looks roughly like this
...
Private Sub cmdAppend_Click()
' ... some code ...
CurrentDb.Execute "Your Append Query", dbFailOnError
' or DoCmd.RunSQL, or DoCmd.OpenQuery
' ... more code ...
End Sub
... then you would do better to establish error-handling in that
procedure. In that case, you *would* refer to Err.Number to identify
the error. It would look something like this:
Private Sub cmdAppend_Click()
On Error GoTo Err_Handler
' ... some code ...
CurrentDb.Execute "Your Append Query", dbFailOnError
' ... more code ...
Exit_Point:
Exit Sub
Err_Handler:
If Err.Number = 10014 Then
MsgBox _
"These samples may have already been entered " & _
"in the database. Select another disk or " & _
"click yes to continue"
Me.Undo
End If
Resume Exit_Point
End Sub

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Randy - 26 Oct 2005 21:17 GMT
Thanks Dirk, you helped me figure it out..Randy
>> The error statement is: "Microsoft Access was unable to append all
>> the data to the table. The contents of fields in 0 records were
[quoted text clipped - 68 lines]
>
> End Sub