Good day guys!
I just want a little help about recordset navigation to act when i click Previous and Next button. I have created the navigation code but it jumps the records on a table..My code below.
'==========================In class module(clsCheque_Navigation)========================
Option Explicit
Private Nav_chkno As String 'Store current page check no.
Private Nav_Recordset As Recordset 'Reference recordset where we will perform the paging
Private nav_mover As Long
'Class Starter
Public Sub Initialize_Navigation(ByRef srcRecordset)
Set Nav_Recordset = srcRecordset
End Sub
Public Sub Navigate_Recordset(onprevious As Boolean, onnext As Boolean)
If onprevious = True Then
nav_mover = nav_mover - 1
End If
If onnext = True Then
nav_mover = nav_mover + 1
End If
'navigate & show the record
Show_NavRecord
End Sub
Private Sub Show_NavRecord()
If Nav_Recordset.eof = True Then
Nav_Recordset.Close
Set Nav_Recordset = Nothing
Exit Sub
End If
If nav_mover > Nav_Recordset.RecordCount - 1 Then
nav_mover = 0
End If
If nav_mover < 0 Then
nav_mover = Nav_Recordset.RecordCount - 1
End If
Nav_Recordset.Move nav_mover
Nav_chkno = Nav_Recordset!checkno
End Sub
'Return the current chkno
Public Function Get_ChequeNo() As String
Get_ChequeNo = Nav_chkno
End Function
Private Sub Class_Initialize()
nav_mover = 0
Nav_chkno = vbNullString
End Sub
Private Sub Class_Terminate()
nav_mover = 0
Nav_chkno = vbNullString
End Sub
'================================In Form Load====================================
option explicit
Dim pagin_nav As New clsCheque_Navigation
If pagingrs.State = adStateOpen Then pagingrs.Close
pagingrs.CursorLocation = adUseClient
pagingrs.Open "Select * from tbl_qb_account_remittances_summary", strConnection, adOpenStatic, adLockReadOnly
pagin_nav.Initialize_Navigation pagingrs
'================================In Previous button Click===============================
pagin_nav.Navigate_Recordset true,false
'==================================In Next button Click=================================
pagin_nav.Navigate_Recordset false,true
Thank you for helping.