Sam Coombes
asked on
Next and Previous buttons
Hi , How do I get this code for previous row entry to work and display in the text boxes. This code is not working and obviously the reverse of this will be the next button. But until this works I cant get the NEXT button to work.
Private Sub Cmdbutton_PREVIOUS_Click()
Dim ws As Worksheet
Set ws = Worksheets("Blueteq")
Dim newRow As Long
newRow = Application.WorksheetFunct ion.CountA (ws.Range( "A:A")) + 1
CurrentRow = CurrentRow - 1
If CurrentRow > 1 Then
TextBox_Initials = Cells(CurrentRow, 1)
TextBox_HNUMBER = Cells(CurrentRow, 2)
DTPicker_DOB = Cells(CurrentRow, 3)
TextBox_NHSNUMBER = Cells(CurrentRow, 4)
TextBox_GPNUMBER = Cells(CurrentRow, 5)
ComboBox_DRUG = Cells(CurrentRow, 6)
ComboBox_INDICATION = Cells(CurrentRow, 7)
DTPicker_STARTDATE = Cells(CurrentRow, 8)
TextBox_CONSULTANT = Cells(CurrentRow, 9)
Me.DTPicker_DATEADDED = Cells(CurrentRow, 10)
ComboBox_Blueteqdrug = Cells(CurrentRow, 11)
ComboBox_FORMLIST = Cells(CurrentRow, 12)
TextBox_BLUETEQID = Cells(CurrentRow, 15)
DTPicker_APPROVALDATE = Cells(CurrentRow, 16)
TextBox_DOCTOR = Cells(CurrentRow, 17)
ComboBox_STATUS = Cells(CurrentRow, 18)
TextBox_EMAIL = Cells(CurrentRow, 19)
TextBox_Commisioners = Cells(CurrentRow, 20)
End If
If CurrentRow = 1 Then
CurrentRow = CurrentRow + 1
End If
End Sub
Private Sub Cmdbutton_PREVIOUS_Click()
Dim ws As Worksheet
Set ws = Worksheets("Blueteq")
Dim newRow As Long
newRow = Application.WorksheetFunct
CurrentRow = CurrentRow - 1
If CurrentRow > 1 Then
TextBox_Initials = Cells(CurrentRow, 1)
TextBox_HNUMBER = Cells(CurrentRow, 2)
DTPicker_DOB = Cells(CurrentRow, 3)
TextBox_NHSNUMBER = Cells(CurrentRow, 4)
TextBox_GPNUMBER = Cells(CurrentRow, 5)
ComboBox_DRUG = Cells(CurrentRow, 6)
ComboBox_INDICATION = Cells(CurrentRow, 7)
DTPicker_STARTDATE = Cells(CurrentRow, 8)
TextBox_CONSULTANT = Cells(CurrentRow, 9)
Me.DTPicker_DATEADDED = Cells(CurrentRow, 10)
ComboBox_Blueteqdrug = Cells(CurrentRow, 11)
ComboBox_FORMLIST = Cells(CurrentRow, 12)
TextBox_BLUETEQID = Cells(CurrentRow, 15)
DTPicker_APPROVALDATE = Cells(CurrentRow, 16)
TextBox_DOCTOR = Cells(CurrentRow, 17)
ComboBox_STATUS = Cells(CurrentRow, 18)
TextBox_EMAIL = Cells(CurrentRow, 19)
TextBox_Commisioners = Cells(CurrentRow, 20)
End If
If CurrentRow = 1 Then
CurrentRow = CurrentRow + 1
End If
End Sub
How about a sample sheet for testing?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's works amazing but why doesn't the add button work after you press the previous button
I did not work on any thing else. What is the add button supposed to do?
ASKER
Thats fantastic works a treat, sorry I was just a little confused earlier but all fixed now
ASKER
Hi , Once again thank you so much but now do you have any idea how to get an upate/edit button to work
You need to explain what you want it to do.