looping through fields

Mcgrco

Registered User.
Local time
Today, 12:28
Joined
Jun 19, 2001
Messages
118
Do Until rs.EOF
For Each fld In rs.Fields

My code starts like this but what i want to do is start the next bit of code only when the rs.fields(1) is at the 5th record. I know I could put it in an index but is there any way of getting the recordset to move down to the 5th field when it is opened. I need to be able to look at the first five fields but I wont need to run any action on them.

Any help would be appreciated
 
Mcgrco,

' *********************************************
Dim dbs As Database
Dim rst As RecordSet
Dim sql As String
Dim lngPtr As Long

Set dbs = CurrentDb
sql = "Select * from MyTable Order by SomeField"
Set rst = dbs.OpenRecordset(sql)
rst.MoveFirst
rst.MoveLast
lngPtr = rst.RecordCount
rst.MoveFirst

For lngPtr = 1 to rst.RecordCount
If lngPtr <= 5 Then
'Code for looking ...
Else
' Other code ...
End If
rst.MoveNext
Next lngPtr
' *********************************************

hth,
Wayne
 
Are you trying to evaluate starting from each record's 5th field or starting from the recordset's 5th record?

It sounds as if you're confusing the 2 'dimensions' of the recordset:

Record1 Field1 Field2 Field3 ...
Record2 Field1 Field2 Field3 ...
Record3 Field1 Field2 Field3 ...
.
.
.
etc.
 

Users who are viewing this thread

Back
Top Bottom