Link to home
Start Free TrialLog in
Avatar of jafre
jafreFlag for United States of America

asked on

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.  


Avatar of Sethi
Sethi
Flag of India image

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
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jafre

ASKER

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
You're not using any loop to read all the entries. Please put a loop with a Not .EOF condition.

Mayank.
Avatar of jafre

ASKER

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.
Avatar of jafre

ASKER

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.
That's strange. Please post the updated code fragment (with the loop).

Mayank.
Avatar of jafre

ASKER

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.
Go ahead -> I always prefer the Data control!

Mayank.
Avatar of CleanupPing
CleanupPing

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?
Recommendation: Points to  mayankeagle
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.
Already recommended. Recommendation: Points to  mayankeagle
Thanks, Sethi!
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer