Solved

Runtime error 3020. What to do?

Posted on 1998-05-07
7
608 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:zsi
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

14 Experts available now in Live!

Get 1:1 Help Now