Hi guys,
I have a custom command button cmdPreviousRec and cmdNextRec for navigation, but when i click the cmdPreviousRec its not navigating to the records and the cmdNextRec is up to 2nd record only.
Please can anyone help me.
Code below is the i've working:
Private Sub cmdNextRec_Click()
On Error Resume Next
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM tblAMHMace")
If Not rs.EOF Then
rs.MoveNext
Me.txtReferenceNo = rs!ReferenceNo
Me.txtDate = rs!DateLog
Me.txtDocType = rs!DocType
Me.txtSubject = rs!Subject
Me.txtRecipient = rs!Recipient
Me.txtCompany = rs!Company
Me.cboInitiator = rs!Initiator
Me.cboStatus = rs!Status
Me.txtPreparedBy = rs!PreparedBy
ElseIf rs.EOF Then
MsgBox "No more records in the database...", , "Database Information"
rs.MoveLast
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub cmdPreviousRec_Click()
On Error Resume Next
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM tblAMHMace")
If Not rs.BOF Then
rs.MovePrevious
Me.txtReferenceNo = rs!ReferenceNo
Me.txtDate = rs!DateLog
Me.txtDocType = rs!DocType
Me.txtSubject = rs!Subject
Me.txtRecipient = rs!Recipient
Me.txtCompany = rs!Company
Me.cboInitiator = rs!Initiator
Me.cboStatus = rs!Status
Me.txtPreparedBy = rs!PreparedBy
ElseIf rs.BOF Then
MsgBox "Moving past the first record...", , "Database Information"
rs.MoveFirst
End If
rs.Close
Set rs = Nothing
End Sub