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 / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

error handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill H. - 06 Nov 2006 01:26 GMT
Have this code fragment.

When I click on the delete command button when on a new record, instead of
the error being handled by Err-DelRec_Click, I just get the access error
window referencing error code 2046.

How do I get it to go to MY handler?

Thx.

Private Sub DelRec_Click()
On Error GoTo Err_DelRec_Click
   DoCmd.RunCommand acCmdDeleteRecord

Exit_DelRec_Click:
   Exit Sub

Err_DelRec_Click:
   Select Case Err.Number
   Case 3200
   Beep
   Case 2046 'tried to delete on new record
   Resume next
   Exit Sub
   End Select
   msgbox Err.Description
   Resume Exit_DelRec_Click
End Sub

Signature

Bill

Allen Browne - 06 Nov 2006 06:49 GMT
You might need to test whether DelRec_Click is firing at all. There may be
another data error occurring. For example, if the cursor is in a partly
filled in date, and you attempt to click the button, Access won't let the
focus out of the active text box until the date is completed, so the
button's Click event is not called at all yet.

If it's not that issue, consider dealing with the obvious possibilities in
your code like this:

   If Me.Dirty Then
       Me.Undo
   End If
   If Not Me.NewRecord Then
       DoCmd.RunCommand acCmdDeleteRecord
   End if

Keep your basic error handling, of course.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Have this code fragment.
>
[quoted text clipped - 24 lines]
>    Resume Exit_DelRec_Click
> 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.