Dim currentrow As Long
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdGetNext_Click()
Dim NameFound As Range
fpath = ThisWorkbook.Path & "\"
Range("A2").Select
ActiveCell.End(xlDown).Select
lastrow = ActiveCell.Row
currentrow = currentrow + 1
If currentrow = lastrow + 1 Then
currentrow = lastrow
MsgBox "You have reached the last row"
End If
With Cells(currentrow, 1)
txtFirstName.Text = Cells(currentrow, 1).Value
Set NameFound = .Find(txtFirstName.Text)
With NameFound
On Error Resume Next
imgData.Picture = LoadPicture(fpath & "nopic.jpg")
imgData.Picture = LoadPicture(fpath & txtFirstName.Text & ".jpg")
End With
End With
txtFirstName.Text = Cells(currentrow, 1).Value
txtLastName.Text = Cells(currentrow, 2).Value
txtMobile.Text = Cells(currentrow, 3).Value
End Sub
Private Sub cmdGetPrevious_Click()
Dim NameFound As Range
fpath = ThisWorkbook.Path & "\"
currentrow = currentrow - 1
If currentrow > 1 Then
txtFirstName.Text = Cells(currentrow, 1).Value
txtLastName.Text = Cells(currentrow, 2).Value
txtMobile.Text = Cells(currentrow, 3).Value
With Cells(currentrow, 1)
txtFirstName.Text = Cells(currentrow, 1).Value
Set NameFound = .Find(txtFirstName.Text)
With NameFound
On Error Resume Next
imgData.Picture = LoadPicture(fpath & "nopic.jpg")
imgData.Picture = LoadPicture(fpath & txtFirstName.Text & ".jpg")
End With
End With
ElseIf currentrow = 1 Then
MsgBox "This is your first record"
currentrow = currentrow + 1
End If
End Sub
Private Sub cmdSend_Click()
Range("A2").Select
ActiveCell.End(xlDown).Select
lastrow = ActiveCell.Row
'MsgBox lastrow
Cells(lastrow + 1, 1).Value = txtFirstName.Text
Cells(lastrow + 1, 2).Value = txtLastName.Text
Cells(lastrow + 1, 3).Value = txtMobile.Text
Range("A2").Select
txtFirstName.Text = ""
txtLastName.Text = ""
txtMobile.Text = ""
End Sub
Private Sub UserForm_Initialize()
currentrow = 1
txtFirstName.Text = ""
txtLastName.Text = ""
txtMobile.Text = ""
End Sub