Results 1 to 4 of 4
  1. #1
    frankatlarge is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    3

    Validation dependent yes/no fields in a form

    Good morning


    Thanks in advance for your assistance. I have two 'yes/no' fields displayed in a form that are dependent and I want to use a validation in the form to prevent them from both being ticked yes but what I've tried doesn't seem to be working.
    The database is for school attendance and the fields are 'Full day' and 'Half day'. They can both be no, or either yes, but not both yes.

    I've tried ([Full day] =-1) XOR ([Half day] =-1) but I'm obviously doing something wrong. Suggestions?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I would use some code in the form's Before Update event. Not tested, but something like:
    Code:
    If Me.[Full Day] = True AND Me.[Half Day] = True Then
      Cancel = True
      Msgbox "'Full Day' and 'Half Day' can't both be Yes"
    End If
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    frankatlarge is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    3

    Thanks I'll give that a go

    Thanks Bob - I'll give that a go when I'm home from work tonight

    Quote Originally Posted by Bob Fitz View Post
    I would use some code in the form's Before Update event. Not tested, but something like:
    Code:
    If Me.[Full Day] = True AND Me.[Half Day] = True Then
      Cancel = True
      Msgbox "'Full Day' and 'Half Day' can't both be Yes"
    End If

  4. #4
    frankatlarge is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    3
    Thanks Bob - worked perfectly. Much appreciated.

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

Similar Threads

  1. (Again) dependent fields,
    By jamal numan in forum Access
    Replies: 12
    Last Post: 10-25-2012, 07:17 AM
  2. I can't seem to get the Validation set for form fields.
    By shane201980 in forum Programming
    Replies: 10
    Last Post: 10-05-2012, 03:08 AM
  3. Replies: 2
    Last Post: 05-16-2012, 03:10 PM
  4. validation of unique fields
    By thanosgr in forum Programming
    Replies: 3
    Last Post: 05-02-2012, 09:59 AM
  5. Validation dependent Text
    By Arrrggggjhhhhh!!!! in forum Forms
    Replies: 3
    Last Post: 02-27-2012, 07:36 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