?
Solved

Runtime error 3020. What to do?

Posted on 1998-05-07
7
Medium Priority
?
690 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 800 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses

850 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