Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

Trouble Trapping Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randy - 26 Oct 2005 19:20 GMT
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"  Ive found
the error number is 10014.  I've placed the following code in the on error
event of my form and tried it on the double click event of the control with
no luck.  I still get the generic error.  Here's the code i've t4ried to
use:  Any ideas?...Thanks..Randy

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
Dirk Goldgar - 26 Oct 2005 19:48 GMT
> 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

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.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Randy - 26 Oct 2005 20:08 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 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.