Dear Experts

I developed a simple project.
The attachment contains one form and a database.

This work fine

But I need source codes for NEXT and BACK buttons

Please unzip and help

I'm guessing you mean for advancing the list views selection?

Private Sub MoveNext()
    If (ListView1.Items.Count = 0) Then
      'Nothing to  selected
    ElseIf (ListView1.SelectedItems.Count = 0) Then
      'Nothing selected, select the first
      ListView1.Items(0).Selected = True
    Else

      Dim idx As Integer
      If (ListView1.Items.Count - 1 > ListView1.SelectedIndices(0)) Then
        idx = ListView1.SelectedIndices(0) + 1 'Select the next item
      Else
        idx = 0 'We're at the end, start at the beginning
      End If
      ListView1.SelectedItems.Clear()
      ListView1.Items(idx).Selected = True
    End If
  End Sub

You should also set ListView1.HideSelection = False in the designer or you won't be able to see the selection position when clicking the next/back button. You should be able to modify the above code to work in reverse.

I'm guessing you mean for advancing the list views selection?

Private Sub MoveNext()
    If (ListView1.Items.Count = 0) Then
      'Nothing to  selected
    ElseIf (ListView1.SelectedItems.Count = 0) Then
      'Nothing selected, select the first
      ListView1.Items(0).Selected = True
    Else

      Dim idx As Integer
      If (ListView1.Items.Count - 1 > ListView1.SelectedIndices(0)) Then
        idx = ListView1.SelectedIndices(0) + 1 'Select the next item
      Else
        idx = 0 'We're at the end, start at the beginning
      End If
      ListView1.SelectedItems.Clear()
      ListView1.Items(idx).Selected = True
    End If
  End Sub

You should also set ListView1.HideSelection = False in the designer or you won't be able to see the selection position when clicking the next/back button. You should be able to modify the above code to work in reverse.

Dear Sir,

If I manually enter 1 in textbox1 then all relevant data displays in other textboxes.

At this point, when there is 1 in textbox1, I call movenext then textbox1 must display next row that is 2.
But when I call movenext then it displays 4.

Please help again

This article has been dead for over six months. Start a new discussion instead.