Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access Recordset.MoveNext actually does .MoveFirst

Status
Not open for further replies.

kepperlepperkeffer

Programmer
Jun 24, 2003
2
GB
Hello Everyone!

I wonder if you can help me. My code below opens, naviagtes, then
closes a recordset. And it works. The only problem is, that I want
the LocateSegment function to find the NEXT value in th recordset, but
all it keeps doing is finding the FIRST. Its as if theres an
imaginary line at the beginning of the LocateSegment function saying
RecordsetIP.MoveFirst

Can you help? I've tried using RecordsetIP.FindNext but it errors
saying "the operateion is not supported for this type of object.

Any ideas would be massively appreciated.

Cheers!
Graeme.



Option Explicit

Dim db As DAO.Database
Dim RecordsetIP As DAO.Recordset 'Input table

Public Function OpenConnections()
Set db = CurrentDb
Set RecordsetIP = db.OpenRecordset("EDI Raw Input")
RecordsetIP.MoveFirst
End Function

Public Function LocateSegment(Segment As String)
Do Until RecordsetIP![Col1] = Segment Or RecordsetIP.EOF = True
RecordsetIP.MoveNext
Loop
End Function

Public Function CloseConnections()
RecordsetIP.Close
Set RecordsetIP = Nothing
db.Close
Set db = Nothing
End Function

Private Sub Form_Load()
OpenConnections
LocateSegment ("LIN") 'search recordset for NEXT occurance of
"LIN"
MsgBox RecordsetIP("Col2")
LocateSegment ("LIN")
MsgBox RecordsetIP("Col2")
LocateSegment ("LIN")
MsgBox RecordsetIP("Col2")

' RecordsetIP.FindNext ("IMD") 'causes error

CloseConnections
End Sub
 
In my limited experience, whenever you open a recordset you have to do a .movelast .movefirst to "populate" the recordset. Otherwise you just end up with one record in the set so a movenext would be the same as a movefirst.

Try doing this;

with RecordsetIP
.movelast
.movefirst
end with

and then try to do what you're doing. I dunno if that'll help or not.


Onwards,

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top