Solved

Runtime Error 3426 Cancelled by association

Posted on 1998-08-05
3
802 Views
Last Modified: 2008-02-01
The error 3426 "this action cancelled by an associated object" is driving me nuts. What causes this error. I have a form and a datacontrol and a TDBlist combobox. Sometimes I think I have fixed it and back it comes. There doesn't seem to be any clear documentation on this error. What causes it and how to stamp it out.
0
Comment
Question by:entretec
3 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1467924
What causes it is the data control.

But seriously, what really causes it is a scenario such as the following:
1. You add a record using TDBList (or edit or delete)
2. Through code you cause an update without "notifying" the data control.
3. You move to the next record, add a new record, etc.
4. The data control tries to do an update and finds that the addnew (or edit) is no longer pending.
5. Bang, you have your error.

The harder part is trying to fix the problem.  It seems to occur mostly with grids, because of the way grids work when you move from row to row.  I've gotten this error more times than I can count and, like you, think I've fixed it only to have it crop up again for no apparent reason.  I finally quit using bound grids and only use them unbound.
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 100 total points
ID: 1467925
According to microsoft:

WORKAROUND
==========
 
To workaround this bug, use the Edit method before the Update method, prior
to saving the changes to a recordset, as shown below:
 
   Data1.RecordSet.Edit
   Data1.RecordSet.Update


What I would do if I was you, in the DBGrid's BeforeUpdate event, call the Edit.. let the DBGrid handle the update itself.
0
 

Expert Comment

by:carlosgomes
ID: 3162372
It seems this is more a time-out error rather than a run-time error. Anyway, I just made a retry routine like this:

While...


On Error Resume Next
Retry:
    DoEvents
    Data1.Recordset.AddNew
    If Err > 0 Then
        Err = 0
        GoTo Retry
    End If
Wend
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 71
Copy a row 12 62
HOW D I CLEAR PICTURES IN IMAGE CONTROL AND COMMENTS IN CELLS WHEN WORKBOOK IS OPENED 18 98
Hide vba in gp 7 95
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question