lucyLocket
Registered User.
- Local time
- Yesterday, 22:42
- Joined
- Dec 24, 2007
- Messages
- 15
I am trying to move through a recordset - on opening the form my textboxes are already populated with the first record, by clicking this button I want to be able to go through to the last record where a messagebox will tell the user it is the last record - nothing is happening and no error message. Can someone help?
Private Sub cmdNextRecord_Click()
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "Select * from staffDetails", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
If Not rec.EOF Then
Do While Not rec.EOF
tbxnINumber = rec.Fields(0)
tbxstaffNo = rec.Fields(1)
tbxdateStarted = rec.Fields(2)
tbxtitle = rec.Fields(3)
tbxfName = rec.Fields(4)
tbxsName = rec.Fields(5)
tbxdob = rec.Fields(6)
tbxmaritalStatus = rec.Fields(7)
tbxaddress1 = rec.Fields(8)
tbxaddress2 = rec.Fields(9)
tbxaddress3 = rec.Fields(10)
tbxaddress4 = rec.Fields(11)
tbxaddress5 = rec.Fields(12)
tbxpostcode = rec.Fields(13)
tbxtelephoneNo = rec.Fields(14)
tbxnextOfKin = rec.Fields(15)
tbxRelationship = rec.Fields(16)
tbxnokTeleNo = rec.Fields(17)
tbxdrivingLicenceNo = rec.Fields(18)
tbxlicenceType = rec.Fields(19)
tbxdateFinished = rec.Fields(20)
rec.MoveNext
Loop
rec.Close
Else
MsgBox "There are no more records"
End If
End Sub
Thanks
Private Sub cmdNextRecord_Click()
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "Select * from staffDetails", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
If Not rec.EOF Then
Do While Not rec.EOF
tbxnINumber = rec.Fields(0)
tbxstaffNo = rec.Fields(1)
tbxdateStarted = rec.Fields(2)
tbxtitle = rec.Fields(3)
tbxfName = rec.Fields(4)
tbxsName = rec.Fields(5)
tbxdob = rec.Fields(6)
tbxmaritalStatus = rec.Fields(7)
tbxaddress1 = rec.Fields(8)
tbxaddress2 = rec.Fields(9)
tbxaddress3 = rec.Fields(10)
tbxaddress4 = rec.Fields(11)
tbxaddress5 = rec.Fields(12)
tbxpostcode = rec.Fields(13)
tbxtelephoneNo = rec.Fields(14)
tbxnextOfKin = rec.Fields(15)
tbxRelationship = rec.Fields(16)
tbxnokTeleNo = rec.Fields(17)
tbxdrivingLicenceNo = rec.Fields(18)
tbxlicenceType = rec.Fields(19)
tbxdateFinished = rec.Fields(20)
rec.MoveNext
Loop
rec.Close
Else
MsgBox "There are no more records"
End If
End Sub
Thanks