• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1675
  • Last Modified:

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

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
jafre
Asked:
jafre
  • 5
  • 4
  • 3
  • +2
1 Solution
 
SethiCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
jafreAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Mayank SAssociate Director - Product EngineeringCommented:
You're not using any loop to read all the entries. Please put a loop with a Not .EOF condition.

Mayank.
0
 
jafreAuthor Commented:
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
 
jafreAuthor Commented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
That's strange. Please post the updated code fragment (with the loop).

Mayank.
0
 
jafreAuthor Commented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
Go ahead -> I always prefer the Data control!

Mayank.
0
 
CleanupPingCommented:
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
 
SethiCommented:
Recommendation: Points to  mayankeagle
0
 
CleanupPingCommented:
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
 
SethiCommented:
Already recommended. Recommendation: Points to  mayankeagle
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Thanks, Sethi!
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now