*** Paste this In worksheet1 code module
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
GetData Target
UserForm1.Show
End Sub
*** End of worksheet module
*** Paste this In the userform code
Option Explicit
Private Sub NextRecord_Click()
RowNum = RowNum + 1
If Cells(RowNum, 1).Value <> vbNullString Then
GetData Cells(RowNum, 1)
Me.Caption = "Record no.: " & RowNum - 1
Else
Beep
RowNum = RowNum - 1
Me.Caption = "Last record in database !!!"
End If
End Sub
Private Sub PreviousRecord_Click()
If RowNum = 2 Then
RowNum = 2
Beep
Me.Caption = "First record in database !!!"
Else
RowNum = RowNum - 1
Me.Caption = "Record no.: " & RowNum - 1
End If
GetData Cells(RowNum, 1)
End Sub
Private Sub UserForm_Activate()
Me.Caption = "Record no.: " & RowNum - 1
End Sub
*** End of userform code
*** Paste this In a normal module
Option Explicit
Public RowNum As Integer
Sub GetData(Optional Target As Range)
If Not Target Is Nothing And Target(, 1).Value <> vbNullString Then
RowNum = Target.Row
Else
RowNum = Target.Row
Do While Cells(RowNum, 1).Value = vbNullString
RowNum = RowNum - 1
Loop
End If
With UserForm1
.TxtName.Value = Cells(RowNum, 2)
.LblDate.Caption = Cells(RowNum, 1)
.TxtServerName.Value = Cells(RowNum, 3)
.TxtLocation.Value = Cells(RowNum, 4)
End With
End Sub
*** End of module
|