Hello all,
I have a userform for data entry purposes of gathering a student's name and selecting an elective class based on preference (1st choice, 2nd choice, 3rd choice). In my userform, I created 3 columns for each of the choices. All 3 columns contain the same list of classes. I decided to use optionbuttons to limit the entry to 1 option per column. I gave each column a GroupName, such as "electiveChoice1" and so on. Each option button refers to a different class and contains the GroupName as well as the optionbutton name G1_01, which right now stands for "Baking", G1_02" stands for Basket Weaving", etc. In each column, the optionbuttons are grouped in the same manner (G2_01, G3_01...both of which are also currently "Baking", but are considered 2nd and 3rd choice preferences). Most of what I have now, I did the pre-work in the properties window for each item.
I have cmdAdd and cmdClose buttons working just fine and have even setup the student's name to be entered into the next blank row of the "dataEntry" page. Now, I just need the value from each "GroupName" to be entered into the 2nd & 3rd column respectively of the "dataEntry" page.
Here's my code so far...
Thank you for your quick response.
JD
I have a userform for data entry purposes of gathering a student's name and selecting an elective class based on preference (1st choice, 2nd choice, 3rd choice). In my userform, I created 3 columns for each of the choices. All 3 columns contain the same list of classes. I decided to use optionbuttons to limit the entry to 1 option per column. I gave each column a GroupName, such as "electiveChoice1" and so on. Each option button refers to a different class and contains the GroupName as well as the optionbutton name G1_01, which right now stands for "Baking", G1_02" stands for Basket Weaving", etc. In each column, the optionbuttons are grouped in the same manner (G2_01, G3_01...both of which are also currently "Baking", but are considered 2nd and 3rd choice preferences). Most of what I have now, I did the pre-work in the properties window for each item.
I have cmdAdd and cmdClose buttons working just fine and have even setup the student's name to be entered into the next blank row of the "dataEntry" page. Now, I just need the value from each "GroupName" to be entered into the 2nd & 3rd column respectively of the "dataEntry" page.
Here's my code so far...
Code:
[B]Modules[/B]
Sub dataEntry_Click()
frmRosterCreator.Show
End Sub
[B]Forms[/B]
Private Sub cmdAdd_Click()
Dim RowCount As Long
Dim fName As String
Dim lName As String
Dim electiveChoice1 As Long
Dim electiveChoice2 As Long
Dim electiveChoice3 As Long
Dim ws As Worksheet
Set ws = Worksheets("dataEntry")
RowCount = dataEntered.Range("A1").CurrentRegion.Rows.Count + 1
With ws
.Cells(RowCount, 1).Value = Me.txtlName.Value
.Cells(RowCount, 2).Value = Me.txtfName.Value
.Cells(RowCount, 3).Value = Me.electiveChoice1.Value
.Cells(RowCount, 4).Value = Me.electiveChoice2.Value
.Cells(RowCount, 5).Value = Me.electiveChoice3.Value
End With
'clear the data
Me.txtlName.Value = ""
Me.txtfName.Value = ""
Me.txtlName.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Thank you for your quick response.
JD