Results 1 to 2 of 2
  1. #1
    thebionicredneck2003 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    22

    Highlight mandatory controls on a form tab on exit

    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

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    As answered elsewhere:

    I typically use Conditional Formatting to highlight controls that still need to be filled out. To do it your way, you want a stand alone test for each rather than ElseIf.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 12-20-2012, 03:06 PM
  2. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  3. form exit problem
    By lavi111 in forum Forms
    Replies: 5
    Last Post: 06-23-2012, 07:23 PM
  4. how to highlight search keywords in results form?
    By Absolute_Beginner in forum Forms
    Replies: 2
    Last Post: 08-22-2011, 04:52 AM
  5. Replies: 0
    Last Post: 10-16-2008, 02:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums