Hello this is my first time writing code so I apologize for how clumsy my code must look.
I have a UserForm(NewProposal) with a Command button (called Customize1, or 2, etc) and a ComboBox(called year 1, etc. - drop down has a range of 1 to 5). The same comboBoxes and command buttons are repeated multiple times with the trailing number just changing. (The names end with a 1, or 2, etc.)
When the command button is clicked it opens up a second userform(CustomizeCosts) with multiple Text Boxes, labels, and comboboxes.
Essentially I want the second userform (CustomizeCosts) to determine which command button called it, and based on that to pull the value of the corresponding combo box. If they chose contract length (years1 combo box) as 1, than I want all the controls on the second form that end with 2-5 to be disabled.
If CommandBox 2 was clicked it would pull the value from combobox2(Years2) and determine which controls should be disabled based on that.
On userform1 i set up a Public WhatsClicked As Integer
The commandbutton 1 code is:
Private Sub BtCustomize1_Click()
If Me.CbYears1 = "" Then
MsgBox "Please Input Number of Years", vbOKOnly, "Number of Years Missing"
Else
WhatsClicked = 1
CustomizeCosts.Show
End If
End Sub
Then under the user form CustomizeCosts initialize i have this code:
Private Sub UserForm_Initialize()
'Dim i As Integer
'Dim x As Integer
'
'x = NewProposal.WhatsClicked.Value
'
'If x.Value = 1 Then
' i = NewProposal.CbYears1.Value
'ElseIf x.Value = 2 Then
' i = NewProposal.CbYears2.Value
'ElseIf x.Value = 3 Then
' i = NewProposal.CbYears3.Value
'ElseIf x.Value = 4 Then
' i = NewProposal.CbYears4.Value
'End If
'
' If i = 1 Then
'
' Me.InitAmount2.Enabled = False
' Me.TbIA2.Enabled = False
' Me.Disc2.Enabled = False
' Me.ComboBox2.Enabled = False
' Me.TxtTotal2.Enabled = False
' Me.Total2.Enabled = False
' Me.InitAmount3.Enabled = False
' Me.TbIA3.Enabled = False
' Me.Disc3.Enabled = False
' Me.ComboBox3.Enabled = False
' Me.TxtTotal3.Enabled = False
' Me.Total3.Enabled = False
' Me.InitAmount4.Enabled = False
' Me.TbIA4.Enabled = False
' Me.Disc4.Enabled = False
' Me.ComboBox4.Enabled = False
' Me.TxtTotal4.Enabled = False
' Me.Total4.Enabled = False
' Me.InitAmount5.Enabled = False
' Me.TbIA5.Enabled = False
' Me.Disc5.Enabled = False
' Me.ComboBox5.Enabled = False
' Me.TxtTotal5.Enabled = False
' Me.Total5.Enabled = False
'
' ElseIf i = 2 Then
'
' Me.InitAmount3.Enabled = False
' Me.TbIA3.Enabled = False
' Me.Disc3.Enabled = False
' Me.ComboBox3.Enabled = False
' Me.TxtTotal3.Enabled = False
' Me.Total3.Enabled = False
' Me.InitAmount4.Enabled = False
' Me.TbIA4.Enabled = False
' Me.Disc4.Enabled = False
' Me.ComboBox4.Enabled = False
' Me.TxtTotal4.Enabled = False
' Me.Total4.Enabled = False
' Me.InitAmount5.Enabled = False
' Me.TbIA5.Enabled = False
' Me.Disc5.Enabled = False
' Me.ComboBox5.Enabled = False
' Me.TxtTotal5.Enabled = False
' Me.Total5.Enabled = False
'
' ElseIf i = 3 Then
'
' Me.InitAmount4.Enabled = False
' Me.TbIA4.Enabled = False
' Me.Disc4.Enabled = False
' Me.ComboBox4.Enabled = False
' Me.TxtTotal4.Enabled = False
' Me.Total4.Enabled = False
' Me.InitAmount5.Enabled = False
' Me.TbIA5.Enabled = False
' Me.Disc5.Enabled = False
' Me.ComboBox5.Enabled = False
' Me.TxtTotal5.Enabled = False
' Me.Total5.Enabled = False
'
' ElseIf i = 4 Then
'
' Me.InitAmount5.Enabled = False
' Me.TbIA5.Enabled = False
' Me.Disc5.Enabled = False
' Me.ComboBox5.Enabled = False
' Me.TxtTotal5.Enabled = False
' Me.Total5.Enabled = False
'
' End If
End Sub
Display More
I have gotten the code to run error free, however none of the controls in the UserForm CostomizeCosts actually end up being disabled.... What am i doing wrong?
Thank You for your help!