Hi everyone,
I am trying to provide a visual highlight for users of a multi tabbed form. I do a check as users go from tab and tab and i.e. on exit event and I would like to highlight all mandatory fields that have been left incomplete.
I did a test with one control and it worked as expected with the after update event of the specific control.
I then altered the code to add another control, but it does not work as expected. It only highlights one control and not the other. I just recently started using vba, so I am open to suggestions so I can adapt the code to fit multiple controls and make it work as expected.
Private Sub Ctl2_frm_tab1_Exit(Cancel As Integer)
If (Len(Form_2.cmb_arName& "") = 0 Or IsNull(Form_2.cmb_arName)) Or _
(Len(Form_2.cmb_val & "") = 0 Or IsNull(Form_2.cmb_val)) Then
Cancel = True
MsgBox "Please complete the highlighted control", vbCritical + vbOKOnly
Form_2.cmb_arName.SetFocus
Form_2.cmb_arName.BorderColor = RGB(255, 0, 0)
Form_2.cmb_val.BorderColor = RGB(255, 0, 0)
ElseIf Len(Form_2.cmb_arName& "") > 0 Or Not IsNull(Form_2.cmb_arName) Or _
Len(Form_2.cmb_val & "") > 0 Or Not IsNull(Form_2.cmb_val) Then
Form_2.cmb_arName.BorderColor = RGB(255, 255, 255)
Form_2.cmb_val.BorderColor = RGB(255, 255, 255)
End If
Exit Sub
End Sub
Many thanks