I have a pop up form with multiple text boxes to enter the information when I click the next button the information that is entered goes into the next blank row. This is the code that I have:
Private Sub cmdNext_Click()
'.End(xlUp) is the same as Ctrl-Up which finds the last non emtpy row and then (1,#) offsets it by one so so it is put down 1 row and over however many rows'
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = txtrelief.Text 'Finds first empty row in column A and enters the relief #'
Range("A" & Rows.Count).End(xlUp)(1, 2) = txtlocation.Text 'Enters the location in the second column'
Range("A" & Rows.Count).End(xlUp)(1, 3) = txtcompressor.Text
Range("A" & Rows.Count).End(xlUp)(1, 4) = txtsub.Text
Range("A" & Rows.Count).End(xlUp)(1, 5) = cbomanu.Text
Range("A" & Rows.Count).End(xlUp)(1, 6) = txtmodel.Text
Range("A" & Rows.Count).End(xlUp)(1, 7) = txtsetting.Text
Me.Hide 'Closes the first form'
Load frmAdd_Relief2 'Opens the second form'
frmAdd_Relief2.Show
Unload Me 'Clears the form so it is blank each time it is opened'
End Sub
On the next page of the form there is a previous button and the code is:
Private Sub cmdPrevious_Click()
Me.Hide 'Closes the second form'
Load frmAdd_Relief1 'Goes back to the first form'
frmAdd_Relief1.Show
End Sub
The problem is that if I click the previous button to go back to the first form, and change a piece of information and click the next button all of the information goes into the next blank row instead of just changing the bit of information that I changed. I feel like there is a quick fix for this but I'm not quite sure what it is.
Private Sub cmdNext_Click()
'.End(xlUp) is the same as Ctrl-Up which finds the last non emtpy row and then (1,#) offsets it by one so so it is put down 1 row and over however many rows'
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = txtrelief.Text 'Finds first empty row in column A and enters the relief #'
Range("A" & Rows.Count).End(xlUp)(1, 2) = txtlocation.Text 'Enters the location in the second column'
Range("A" & Rows.Count).End(xlUp)(1, 3) = txtcompressor.Text
Range("A" & Rows.Count).End(xlUp)(1, 4) = txtsub.Text
Range("A" & Rows.Count).End(xlUp)(1, 5) = cbomanu.Text
Range("A" & Rows.Count).End(xlUp)(1, 6) = txtmodel.Text
Range("A" & Rows.Count).End(xlUp)(1, 7) = txtsetting.Text
Me.Hide 'Closes the first form'
Load frmAdd_Relief2 'Opens the second form'
frmAdd_Relief2.Show
Unload Me 'Clears the form so it is blank each time it is opened'
End Sub
On the next page of the form there is a previous button and the code is:
Private Sub cmdPrevious_Click()
Me.Hide 'Closes the second form'
Load frmAdd_Relief1 'Goes back to the first form'
frmAdd_Relief1.Show
End Sub
The problem is that if I click the previous button to go back to the first form, and change a piece of information and click the next button all of the information goes into the next blank row instead of just changing the bit of information that I changed. I feel like there is a quick fix for this but I'm not quite sure what it is.