No Current Record ????????? Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The Error:
"No Current Record"

The Code:
For Each fldTrail In rsTrail.Fields <== the error
If IsNull(fldTrail.Value) Then
work1 = work1 & sizestr(fldTrail.Value, fldTrail.Size)
Else
If fldTrail.Type = dbDate Then
work1 = work1 & sizedate(fldTrail.Value, DateType)
Else
work1 = work1 & sizestr(fldTrail.Value, fldTrail.Size)
End If
End If
Next fldTrail

Details:
This code gives the above error about 1 of 4 times it is run avg.
What condition will cause the error "No Current Record"?

I can run the CDSN clearance button right now and get an error.
I can run it a again and it will NOT give an error. ?!?!?!?!?!!!!!!
I have to cut out the error.

Scott Burke
 
Where does rsTrail come from?
Did you OpenRecordset?
Did you assign the RecordsetClone of a form?
Did you previously to a Seek or Find or Delete or AddNew?

Some cases where this can occur:
a) rsTrail has no records, there will be no current record.
Solution: test rsTrail.RecordCount

b) You performed a Find that did not result in a match.
There is therefore no current record.
Solution: test rsTrail.NoMatch

c) You have looped through the records past the end
(or looped backwards past the first record).
Solution: test rsTrail.EOF (or for the 2nd case, rsTrail.BOF)

It is also possible to get the error after a Delete or AddNew.
 
Hi Allen, Thank you for time.

I checked each of those options. As it turns out it was a combination of b
and c.

I like to state that this program was written by someone else. I would NOT
have written the code the way he/she did.

AS it turns out, about 30 lines up the code he/she had a loop. If the value
was not found you ended up in .EOF.
I did test for both .NoMatch and .RecordCount but because of the loop the
values were wrong.

Thanks again.
Scott Burke
 
Back
Top