Results 1 to 2 of 2
  1. #1
    usmcgrunt's Avatar
    usmcgrunt is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Just outside the gates of freedom
    Posts
    71

    Form field validation question

    I am trying to highlight fields on a form that the user is required to fill in. The code works on the OnOpen event and if I put it behind a button control. However, no matter where I put the code it will not auto update after the user moves through each field on the form. What am I missing here? I thought that every time the user changes or enters a value in one of the fields on the report, that would be able to trigger a beforeupdate or afterupdate event. Not the case. If the field is highlighted yellow and the user enters a value and then leaves the field it still stays yellow. I am trying to avoid having to put the below code behind every one of the 15 required fields on this form. Thanks for the help.

    I have tried the BeforeUpdate, AfterUpdate, and OnDirty events.

    Code:
    Dim ctl As Control
               
    For Each ctl In Me.Controls
       Select Case ctl.ControlType
           Case acTextBox, acComboBox
               If ctl.Tag = "Required" And IsNull(ctl) Or ctl = "" Then
                   ctl.BackColor = vbYellow
               Else
                   ctl.BackColor = vbWhite
               End If
       End Select
    Next ctl


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    As far as I know, each control's AfterUpdate event will have to be set.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Validation rule question
    By julius in forum Access
    Replies: 0
    Last Post: 02-25-2012, 04:10 PM
  2. Replies: 3
    Last Post: 02-23-2012, 01:26 AM
  3. Question about Validation Rules
    By WilsonsW in forum Access
    Replies: 1
    Last Post: 04-18-2011, 05:06 PM
  4. Validation Question
    By ksmithson in forum Forms
    Replies: 1
    Last Post: 07-15-2010, 03:02 PM
  5. Form Field Validation
    By dhav79 in forum Forms
    Replies: 3
    Last Post: 06-03-2010, 11:31 AM

Tags for this Thread

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