Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

run time error '-2147217842 (80040e4e)':

Posted on 2003-03-13
16
Medium Priority
?
1,555 Views
Last Modified: 2007-12-19
I'm getting this run time error on  .MoveNext using a
dataenvironment connection, connecting to an Access db,
that has a sql statement in the command to select the
desired data.  The error occurs when it doesn't seem to
recognize EOF.  


0
Comment
Question by:jafre
[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
  • 5
  • 4
  • 3
  • +2
16 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 8132700
If you are on the last record of the recordset and you use .MoveNext or if the recordset is empty and you use .Movenext then this error will take place. Always use If conditions with Move methods. Example:
If rs.EOF=False then
rs.MoveNext
end if

Similarly to move previous:
If rs.BOF=False then
rs.MovePrevious
End if
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 80 total points
ID: 8134100
Put your code in this format:


Data1.DatabaseName = "...." ' whatever is the path of your .mdb file
Data1.RecordSource = "SELECT * FROM ...... " ' whatever the query is, or let it be a whole table itself
Data1.Refresh

With Data1.Recordset
  If .EOF Then
    MsgBox "No macth found! "
  Else
    Do While Not .EOF
      ' process individual attributes as ![AttributeName]
      .MoveNext
    End Loop
  End If
End With


It is guaranteed to run. If it gives any problems, please let me know.

Mayank.
0
 

Author Comment

by:jafre
ID: 8134533
This is the code I'm using.  It passes the EOF after the last record is reached and errors on the MoveNext.
With DataEnvironment1.rsFilterCustJobs
    If .EOF = True Then
        Beep
    Else
        .MoveNext
        If .EOF Then
            .MoveLast
        End If
    End If
    End With
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 30

Expert Comment

by:Mayank S
ID: 8134556
You're not using any loop to read all the entries. Please put a loop with a Not .EOF condition.

Mayank.
0
 

Author Comment

by:jafre
ID: 8134572
Thank you for the suggestion of the Do While loop.  Putting it in the code looped through the data and got the same error.  For some reason it doesn't seem to know when it hits EOF.  It trys to get another record after EOF.
0
 

Author Comment

by:jafre
ID: 8134593
Thank you for the suggestion of the Do While loop.  Putting it in the code looped through the data and got the same error.  For some reason it doesn't seem to know when it hits EOF.  It trys to get another record after EOF.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8134594
That's strange. Please post the updated code fragment (with the loop).

Mayank.
0
 

Author Comment

by:jafre
ID: 8136996
With DataEnvironment1.rsfilterCustJobs
'suggested code from expert exchange
If .EOF Then
   MsgBox "No match found! "
 Else
   Do While Not .EOF
     ' process individual attributes as ![AttributeName]
     .MoveNext
     'Exit loop to stop processing records after 1 is found
     Exit Do
   Loop
 End If
end with

Here is the tested code.  If errors on the .MoveNext when pressing the NextRecord button when the last records is already displayed.  The 'Exit Do' had to be added or the loop went to the end of all the records on the first click of the button and erroring when it passed EOF.

On this Microsoft KnowledgeBase web pages http://support.microsoft.com/default.aspx?scid=kb;en-us;249350
 This article describes this run time error as a bug in VB on MoveNext.  Supposedly it was fixed in Visual Studio SP5.  The test I ran after installing SP5 did not change.  The error is still there. Darn!  The sample code in the article edits data in a text box.  In my code all I'm doing is moving to the next record changing no data.  A solution is given - "The resolution is to issue a Recordset.Move 0 method in one of the events in the TextBox control."

I will probably replace the data environment with the old data control which seems more stable.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8137287
Go ahead -> I always prefer the Data control!

Mayank.
0
 

Expert Comment

by:CleanupPing
ID: 8900130
jafre:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 18

Expert Comment

by:Sethi
ID: 8907956
Recommendation: Points to  mayankeagle
0
 

Expert Comment

by:CleanupPing
ID: 9056349
jafre:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9063869
Already recommended. Recommendation: Points to  mayankeagle
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9064286
Thanks, Sethi!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9692946
Moderator, my recommended disposition is:

    Accept mayankeagle's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

722 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