Option Explicit
Private ItemIndex As Long
Private ItemCount As Long
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdFirst_Click()
ItemIndex = 1
Call DisplayDetails
End Sub
Private Sub cmdLast_Click()
Dim dcount As Double
ItemIndex = ItemCount
Call DisplayDetails
End Sub
Private Sub cmdNext_Click()
Dim nxtrow As Long
Dim count As Long
ItemIndex = ItemIndex + 1
Call DisplayDetails
End Sub
Private Sub cmdPrev_Click()
Dim nxtrow As Long
ItemIndex = ItemIndex - 1
Call DisplayDetails
End Sub
Private Sub cmdPrintCurrent_Click()
FrmCompMaint.PrintForm
End Sub
Private Sub UserForm_Initialize()
Dim count As Double
Dim row As Double
'select the correct worksheet
Sheets("TblComponentDetail").Select
'identify which row is selected
ItemIndex = 1
'count how many records
ItemCount = Application.WorksheetFunction.CountA(Range("A:A")) - 1
Call DisplayDetails
End Sub
Private Sub DisplayDetails()
Me.Caption = "Record " & ItemIndex & " of " & ItemCount
With Worksheets("TblComponentDetail")
Me.txtDVD.Value = ItemIndex
Me.txtPrem.Value = .Cells(ItemIndex + 1, 3).Value
Me.txtGroup.Value = .Cells(ItemIndex + 1, 4).Value
Me.txtType.Value = .Cells(ItemIndex + 1, 5).Value
Me.txtDescription.Value = .Cells(ItemIndex + 1, 6).Value
Me.txtMake.Value = .Cells(ItemIndex + 1, 7).Value
Me.txtQuoteDesc.Value = .Cells(ItemIndex + 1, 32).Value
End With
With Me
.cmdPrev.Enabled = ItemIndex <> 1
.cmdNext.Enabled = ItemIndex <> ItemCount
End With
End Sub