Private Sub UserForm_Initialize()
Dim MyArray As Variant
Dim Ctr As Integer
' Populate options on userform
MyArray = Array("On duty", "Off duty ", "On call", "On vacation")
For Ctr = LBound(MyArray) To UBound(MyArray)
For n = 1 To 7
Controls("ComboBox" & n).Enabled = False
Controls("ComboBox" & n).AddItem MyArray(Ctr)
Next n
Next Ctr
End Sub
Private Sub TextBox1_Change()
' Make sure that the textbox and combobox has text in them before activating the Enter button, _
but also safeguarding to keep the Enter button activated if another textbox/ combobox combination _
are filled in
' Start off by disenabling the Enter button
OK_Button.Enabled = False
' If the textbox is filled in then activate the combobox _
Check the status of the other textbox/ comboboxes before activating/ deactivating the Enter button
If TextBox1.Text <> "" Then
ComboBox1.Enabled = True
Select Case True
Case TextBox2.Text <> "" And ComboBox2 = ""
OK_Button.Enabled = False
Case TextBox3.Text <> "" And ComboBox3 = ""
OK_Button.Enabled = False
Case TextBox4.Text <> "" And ComboBox4 = ""
OK_Button.Enabled = False
Case TextBox5.Text <> "" And ComboBox5 = ""
OK_Button.Enabled = False
Case TextBox6.Text <> "" And ComboBox6 = ""
OK_Button.Enabled = False
Case TextBox7.Text <> "" And ComboBox7 = ""
OK_Button.Enabled = False
Case Else
OK_Button.Enabled = OK_Button.Enabled And ComboBox1.Enabled
End Select
Else
ComboBox1.Enabled = False
Select Case True
Case TextBox2.Text <> "" And ComboBox2 <> ""
OK_Button.Enabled = True
Case TextBox3.Text <> "" And ComboBox3 <> ""
OK_Button.Enabled = True
Case TextBox4.Text <> "" And ComboBox4 <> ""
OK_Button.Enabled = True
Case TextBox5.Text <> "" And ComboBox5 <> ""
OK_Button.Enabled = True
Case TextBox6.Text <> "" And ComboBox6 <> ""
OK_Button.Enabled = True
Case TextBox7.Text <> "" And ComboBox7 <> ""
OK_Button.Enabled = True
Case Else
OK_Button.Enabled = False
End Select
End If
End Sub
Private Sub ComboBox1_Change()
' Start off by disenabling the Enter button
OK_Button.Enabled = False
' Enable the Enter button if the Textbox has something in it
OK_Button.Enabled = (ComboBox1.Text <> "")
End Sub
Private Sub TextBox2_Change()
' Make sure that the textbox and combobox has text in them before activating the Enter button, _
but also safeguarding to keep the Enter button activated if another textbox/ combobox combination _
are filled in
' Start off by disenabling the Enter button
OK_Button.Enabled = False
' If the textbox is filled in then activate the combobox _
Check the status of the other textbox/ comboboxes before activating/ deactivating the Enter button
If TextBox2.Text <> "" Then
ComboBox2.Enabled = True
Select Case True
Case TextBox1.Text <> "" And ComboBox1 = ""
OK_Button.Enabled = False
Case TextBox3.Text <> "" And ComboBox3 = ""
OK_Button.Enabled = False
Case TextBox4.Text <> "" And ComboBox4 = ""
OK_Button.Enabled = False
Case TextBox5.Text <> "" And ComboBox5 = ""
OK_Button.Enabled = False
Case TextBox6.Text <> "" And ComboBox6 = ""
OK_Button.Enabled = False
Case TextBox7.Text <> "" And ComboBox7 = ""
OK_Button.Enabled = False
Case Else
OK_Button.Enabled = OK_Button.Enabled And ComboBox2.Enabled
End Select
Else
ComboBox2.Enabled = False
Select Case True
Case TextBox1.Text <> "" And ComboBox1 <> ""
OK_Button.Enabled = True
Case TextBox3.Text <> "" And ComboBox3 <> ""
OK_Button.Enabled = True
Case TextBox4.Text <> "" And ComboBox4 <> ""
OK_Button.Enabled = True
Case TextBox5.Text <> "" And ComboBox5 <> ""
OK_Button.Enabled = True
Case TextBox6.Text <> "" And ComboBox6 <> ""
OK_Button.Enabled = True
Case TextBox7.Text <> "" And ComboBox7 <> ""
OK_Button.Enabled = True
Case Else
OK_Button.Enabled = False
End Select
End If
End Sub
Private Sub ComboBox2_Change()
' Start off by disenabling the Enter button
OK_Button.Enabled = False
' Enable the Enter button if the Textbox has something in it
OK_Button.Enabled = (ComboBox2.Text <> "")
End Sub