0

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.

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by blocker
0

[yoda voice]over complicate things, you do[/yoda voice]

Okay, well maybe not, but using the move method to navigate is your problem...(1+1=2 so move 2 will skip a record...)

You should use the movefirst, moveprevious, movenext, and movelast properties and things will be a lot easier for you (but keep the counter variable, add a recordcount variable for testing if you wish, and things should work out)...

Good Luck

0

Thanks. But whats the most possible fastest way to look this records? I'm having thousands of records in a table to navigate too. And also, can you show the simplest solution if i made my solution complicated.?

Thanks again.!!

0

thanks. If its the most fastest way then ill go for it.

This solved..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.