Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Runtime error 3020. What to do?

Posted on 1998-05-07
7
Medium Priority
?
672 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
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…
Suggested Courses

618 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