Solved

Runtime error 3020. What to do?

Posted on 1998-05-07
7
619 Views
Last Modified: 2008-02-01
On running my app (VB5) I get a run-time error 3020: "update or CancelUpdate without AddNew or Edit".

What does this mean?
How can I detect it (I don't get the error when running in design mode)?
What to do with it?

On error resume next doesn't seem to work.
0
Comment
Question by:Diver
  • 4
  • 3
7 Comments
 
LVL 4

Accepted Solution

by:
zsi earned 200 total points
ID: 1443099
Diver,

This error occurs when you try to invoke the Update or CancelUpdate method on a database or recordset object.  Most likwely, you have opened a database/query and have tried to execute this method.  You might be having an error that causes you to jump to another location in your code (as instructed by an ON ERROR GOTO xxx statement) and you are executing the Update or CancelUpdate method there.  This error is occuring before you open the database/query/recordset for editing.

Hope this helps!
zsi
0
 
LVL 1

Author Comment

by:Diver
ID: 1443100
There is no on error goto statement in the code. And the sad thing is that I do not know where the error comes from.

What you told me here is absolutely true, but it won't help me that way.

Is there a way to find out where exactly the error occurs? And why is this error not occuring when running the code in design time?
0
 
LVL 4

Expert Comment

by:zsi
ID: 1443101
If the code is not too large, you can e-mail it to me at expert@zs.com and I will take a look at it.  Please tell me where the error is occuring (what routine).  

zsi
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:zsi
ID: 1443102
Diver,

I took a look at your code and the solution is simple.

At the various points where you are invoking the UpdateRecord method of your datacontrol, insert the following code around it.

As an example, in your routine imgNext_Click:
     If (datSpeelrondeRS.Recordset.EditMode = dbEditAdd) or (datSpeelrondeRS.Recordset.EditMode = dbEditInProgress) Then
          datSpeelrondeRS.Recordset.Update
     End If

Here is more information on the EditMode property from the VB Help file.

zsi
====================================
Returns a value that indicates the state of editing for the current record.

Syntax

object.EditMode

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The EditMode property returns the following values:

Value      Description

dbEditNone      No editing operation is in progress.
dbEditInProgress      Edit method has been invoked, and the current record is in the copy buffer.
dbEditAdd      AddNew method has been invoked, and the current record in the copy buffer is a new record that hasn't been saved in the database.

These constants are listed in the Data Access (DAO) object library in the Object Browser.

Remarks

The EditMode property is most useful when you want to depart from the default functionality of a Data control or if you aren't using a Data control with Visual Basic Professional Edition.  You can check the value of the EditMode property and the value of the action parameter in the Validate event procedure to determine whether to invoke the Update method.
You can also check to see if the LockEdits property setting is True and the EditMode property setting is dbEditInProgress to determine whether the current data page is locked.
0
 
LVL 1

Author Comment

by:Diver
ID: 1443103
Sorry to tell you, but it still doesn't work.
Some strange things happen here: when I click the imgNext I get the same error on the last click; when I invoke this same procedure from the tab key (lost focus event) I don't get the runtime error!
When I click imgExit, which is basically the same procedure as imgNext, ... no error!

Believe me, I'm quite desperate now. Can you imagine what's happening?

Thanks for your help.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1443104
Diver,

In your imgNext.Click event, there is code that calls the Update method of the data control's recordset.  This code needs to be wrapped with the code explained above.

This update will not happen if you use the Tab key to get to the button (instead of clicking on it) because tabbing to a control does not invoke that control's Click event; only it's GotFocus event.  

As for the imgExit code - the recordset might not be in a state of "non-edit".  It is difficult to say as I cannot run your app here.

0
 
LVL 1

Author Comment

by:Diver
ID: 1443105
Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now