next data entry on userform

cmccabe

Active Member
Joined
Feb 20, 2008
Messages
396
I am trying to create a button on a userform that will goto the next entry. The code that I am using (although it is not working). Thank you.

The userform is called frmData, txt is a text box, cbo is a combobox, and cb is a checkbox.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Private Sub btnNext_Click()
CurRow = Range("CurRow").Value
Range("A" & CurRow).Value = frmData.txtCase.Text
Range("B" & CurRow).Value = frmData.txtEnd.Text
Range("C" & CurRow).Value = frmData.txtReview.Text
Range("D" & CurRow).Value = frmData.cboDx.Text
Range("E" & CurRow).Value = frmData.txtAge.Text
Range("F" & CurRow).Value = frmData.cboAge.Text
Range("G" & CurRow).Value = frmData.cboGnder.Text
Range("H" & CurRow).Value = frmData.cboStatus.Text
Range("I" & CurRow).Value = frmData.cbLSAB.Value
Range("J" & CurRow).Value = frmData.cbSSPHR.Value
Range("K" & CurRow).Value = frmData.cbSSPLR.Value
Range("L" & CurRow).Value = frmData.cbSBT.Value
Range("M" & CurRow).Value = frmData.cboDonor.Text
Range("N" & CurRow).Value = frmData.txtType.Text
Range("O" & CurRow).Value = frmData.txtKey.Text
If CurRow = Range("A65536").End(xlUp).Row Then GoTo LastRec
CurRow = CurRow + 1
Range("CurRow").Value = CurRow
frmData.txtCase.Value = Range("A" & CurRow).Value
frmData.txtEnd.Value = Range("B" & CurRow).Value
frmData.txtReview.Value = Range("C" & CurRow).Value
frmData.cboDx.Value = Range("D" & CurRow).Value
frmData.txtAge.Value = Range("E" & CurRow).Value
frmData.cboAge.Value = Range("F" & CurRow).Value
frmData.cboGender.Value = Range("G" & CurRow).Value
frmData.cboStatus.Value = Range("H" & CurRow).Value
frmData.cbLSAB.Value = Range("I" & CurRow).Value
frmData.cbSSPHR.Value = Range("J" & CurRow).Value
frmData.cbSSPLR.Value = Range("K" & CurRow).Value
frmData.cbSBT.Value = Range("L" & CurRow).Value
frmData.cboDonor.Value = Range("M" & CurRow).Value
frmData.txtType.Value = Range("N" & CurRow).Value
frmData.txtKey.Value = Range("O" & CurRow).Value
Exit Sub
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
What is the code meant to do?

You seem to be putting values on a worksheet and getting values from a worksheet.

If you just want to move to the next record you don't need to write to the worksheet, unless you want to save the current record.

Even if you do want to save the current record that should probably be done using a separate sub, perhaps triggered by a 'Save' button on the form.
 
Upvote 0
After the data values are entered onto the userform , there are two buttons on the userform:

One that transfers the data entered back to a spreadsheet.

The other advances to a new data entry (that is what does not work).

The code is what behind that button. Thank you.
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,611
Members
452,931
Latest member
The Monk

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top