jafre
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.rsFilterC ustJobs
If .EOF = True Then
Beep
Else
.MoveNext
If .EOF Then
.MoveLast
End If
End If
End With
With DataEnvironment1.rsFilterC
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.
Mayank.
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.
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.
Mayank.
ASKER
With DataEnvironment1.rsfilterC ustJobs
'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.
'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.
Mayank.
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?
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.
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
Accept mayankeagle's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
If rs.EOF=False then
rs.MoveNext
end if
Similarly to move previous:
If rs.BOF=False then
rs.MovePrevious
End if