I have a userform set up so that when the "Enter" button is pressed, if any text box is empty, it will set focus and change its background colour to highlight the missing entry.
This works fine as per my excerpt from my code below. But I was wondering if it would be possible to in essence remove the focus event once someone starts to type something in the box that previously had nothing in it?
Private Sub EnterBut_Click() If cbThreat.ListIndex < 1 Then MsgBox "Select threat level!", vbExclamation + vbOKOnly, "Triage Hub" cbThreat.SetFocus cbThreat.BackColor = RGB(102, 255, 255) GoTo lbl_Exit End If If cbHarm.ListIndex < 1 Then MsgBox "Select harm level!", vbExclamation + vbOKOnly, "Triage Hub" cbHarm.SetFocus cbHarm.BackColor = RGB(102, 255, 255) GoTo lbl_Exit End If If cbOpportunity.ListIndex < 1 Then MsgBox "Select opportunity level!", vbExclamation + vbOKOnly, "Triage Hub" cbOpportunity.SetFocus cbOpportunity.BackColor = RGB(102, 255, 255) GoTo lbl_Exit End If If cbRisk.ListIndex < 1 Then MsgBox "Select risk level!", vbExclamation + vbOKOnly, "Triage Hub" cbRisk.SetFocus cbRisk.BackColor = RGB(102, 255, 255) GoTo lbl_Exit End If If cbDepartment.ListIndex < 1 Then MsgBox "Select department to follow up!", vbExclamation + vbOKOnly, "Triage Hub" cbDepartment.SetFocus cbDepartment.BackColor = RGB(102, 255, 255) GoTo lbl_Exit End If If txtRationale.Text = vbNullString Then MsgBox "Enter rationale!", vbExclamation + vbOKOnly, "Triage Hub" txtRationale.SetFocus txtRationale.BackColor = RGB(255, 255, 204) GoTo lbl_Exit End If Tag = 1 Hide lbl_Exit: Exit Sub End Sub




Reply With Quote