I was wondering if there was a possible solution available for the repetion of code that relates to multiple objects (combobox's, buttons, check box's) on a user form?
I have a form that contains a multipage tab (7 pages/tabs) and on each page there are objects that are duplicated on the other pages but with slightly different names to distinguish which pages they are on e.g. cboxCheckBox1Page1, cboxCheckBox2Page1, cboxCheckBox1Page2, cboxCheckBox2Page2, etc, etc.
Example of code for Checkbox's
Basically, I was hoping there was one piece of code that will cater for each of the 42 checkbox's on the 7 tabs and also the numerous combobox's and buttons that do similar things.
Thanks
I have a form that contains a multipage tab (7 pages/tabs) and on each page there are objects that are duplicated on the other pages but with slightly different names to distinguish which pages they are on e.g. cboxCheckBox1Page1, cboxCheckBox2Page1, cboxCheckBox1Page2, cboxCheckBox2Page2, etc, etc.
Example of code for Checkbox's
Code:
Private Sub cboxCopyPriorTueWk1_Click()
If cboxCopyPriorTueWk1 = True Then
boolPopulateForm = True
cbCoreStartTueWk1 = cbCoreStartMonWk1
cbCoreFinishTueWk1 = cbCoreFinishMonWk1
boolPopulateForm = False
boolTueWk1Correct = True
cboxCopyPriorWedWk1.Enabled = True
cbCoreStartTueAll.Enabled = False
cbCoreFinishTueAll.Enabled = False
btnTueAllShift1.Enabled = False
btnTueAllShift2.Enabled = False
btnTueAllShift3.Enabled = False
btnTueAllShift4.Enabled = False
Else
End If
End Sub
Code:
Private Sub cboxCopyPriorWedWk1_Click()
If cboxCopyPriorWedWk1 = True Then
boolPopulateForm = True
cbCoreStartWedWk1 = cbCoreStartTueWk1
cbCoreFinishWedWk1 = cbCoreFinishTueWk1
boolPopulateForm = False
boolWedWk1Correct = True
cboxCopyPriorThuWk1.Enabled = True
cbCoreStartWedAll.Enabled = False
cbCoreFinishWedAll.Enabled = False
btnWedAllShift1.Enabled = False
btnWedAllShift2.Enabled = False
btnWedAllShift3.Enabled = False
btnWedAllShift4.Enabled = False
Else
End If
End Sub
Code:
Private Sub cboxCopyPriorTueWk2_Click()
If cboxCopyPriorTueWk2 = True Then
boolPopulateForm = True
cbCoreStartTueWk2 = cbCoreStartMonWk2
cbCoreFinishTueWk2 = cbCoreFinishMonWk2
boolPopulateForm = False
boolTueWk2Correct = True
cboxCopyPriorWedWk2.Enabled = True
cbCoreStartTueAll.Enabled = False
cbCoreFinishTueAll.Enabled = False
btnTueAllShift1.Enabled = False
btnTueAllShift2.Enabled = False
btnTueAllShift3.Enabled = False
btnTueAllShift4.Enabled = False
Else
End If
End Sub
Code:
Private Sub cboxCopyPriorWedWk2_Click()
If cboxCopyPriorWedWk2 = True Then
boolPopulateForm = True
cbCoreStartWedWk2 = cbCoreStartTueWk2
cbCoreFinishWedWk2 = cbCoreFinishTueWk2
boolPopulateForm = False
boolWedWk2Correct = True
cboxCopyPriorThuWk2.Enabled = True
cbCoreStartWedAll.Enabled = False
cbCoreFinishWedAll.Enabled = False
btnWedAllShift1.Enabled = False
btnWedAllShift2.Enabled = False
btnWedAllShift3.Enabled = False
btnWedAllShift4.Enabled = False
Else
End If
End Sub
Thanks