I googled this, but could not find an answer that fit the criteria of my code/event... so here is my problem:
I have a simple procedure that after a user tries to close out a userform (via a command button), if certain checkboxes are NOT 'ticked' then it gives them a simple warning box along with changing the color to yellow for the choice of boxes where one of them must be selected:
My code:
After googling, I read where after the MsgBox 'ok' is clicked the very next line of code in the module will be ran next, but, no matter where I put the code to put the color back to the original userform color, it doesn't follow/perform it.
After hitting 'ok' I simply need the boxes/labels to revert back to this:
so this does not give the effect I am looking for:
I have a simple procedure that after a user tries to close out a userform (via a command button), if certain checkboxes are NOT 'ticked' then it gives them a simple warning box along with changing the color to yellow for the choice of boxes where one of them must be selected:
My code:
VBA Code:
' Only allow selection of Hourly Check Box -OR- Salary Check Box, but not BOTH (turn both boxes YELLOW if neither are selected)
If Me.chkHourly = False And Me.chkSalary = False Then
Me.chkSalary.SetFocus
Me.chkSalary.BackColor = &HFFFF&
Me.lblSalary.BackColor = &HFFFF&
Me.lblHourly.BackColor = &HFFFF&
Me.chkHourly.BackColor = &HFFFF&
MsgBox "You must Select either Hourly or Salary"
Exit Sub
End If
After googling, I read where after the MsgBox 'ok' is clicked the very next line of code in the module will be ran next, but, no matter where I put the code to put the color back to the original userform color, it doesn't follow/perform it.
After hitting 'ok' I simply need the boxes/labels to revert back to this:
so this does not give the effect I am looking for:
VBA Code:
' Only allow selection of Hourly Check Box -OR- Salary Check Box, but not BOTH (turn both boxes YELLOW if neither are selected)
If Me.chkHourly = False And Me.chkSalary = False Then
Me.chkSalary.SetFocus
Me.chkSalary.BackColor = &HFFFF&
Me.lblSalary.BackColor = &HFFFF&
Me.lblHourly.BackColor = &HFFFF&
Me.chkHourly.BackColor = &HFFFF&
MsgBox "You must Select either Hourly or Salary"
' recolor the backcolor of the labels/checkboxes back to the userform template color after user hits 'ok' for the msgbox:
Me.chkSalary.BackColor = &HC8DAC6
Me.lblSalary.BackColor = &HC8DAC6
Me.lblHourly.BackColor = &HC8DAC6
Me.chkHourly.BackColor = &HC8DAC6
Exit Sub
End If