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

    Combining two boolean values

    Hey guys,



    Here's my problem. I basically have two yes/no fields in an access table. I want field one to have the value yes if field two has value no, and the other way arround.

    I had a look at the Boolean operators, but im not sure where to go from there.

    Can anyone help me out ? I suppose theres a simple solution.

    Best Regards,

    John

  2. #2
    dodo47 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Roma (Italy)
    Posts
    13
    Hi
    try in the after update event of each boolean filed:
    Code:
    Private Sub MyYesNo1_AfterUpdate()
    Me.MyYesNo1 = True = Me.MyYesNo2 = False
    End Sub
    
    Private Sub MyYesNo2_AfterUpdate()
    Me.MyYesNo1 = True = Me.MyYesNo2 = False
    End Sub
    or something else like it

    regards

  3. #3
    John_B is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    3
    Hi Dodo47

    Thanks for you help so far. Is the code you provided only applicable in a form or can i also apply it directly to the yes/no fields?

    Also im not quite sure where to find the "after update event of each boolean filled".

    Thanks again in advance!

  4. #4
    dodo47 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Roma (Italy)
    Posts
    13
    Apologise...
    i have 2003.... and don't know if 2010 has same structure, anyway

    In forms structure:
    right click the yes/no field > property > events

    I don't think that you can this in costruction table

    regards

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    Just curious, why you need 2 such fields and a condition that if one is Yes then the other is No.
    If you have one field that has only 2 possible values, seems you could determine the values by reading that one field.

    Anyway, just a thought.

    Perhaps you could describe the 2 fields and what you are trying to do.

  6. #6
    John_B is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    3
    I basically have a couple of tables. One of them is called "Students". In that table i have two fields wich are called "present" and "absent".

    The students are physically carrying passes arround that grants them entry to the school if a couple of conditions are true. One of them would be that a student can only access the school if the checkbox "absent" is checked, and only leave the school if the checkbox "present" is checked.

    I might be able to use one boolean tho. How would i configure that?

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    What if you had 1 field called CurrentStatus, and it could have 2 values
    1- Present
    2 -Absent
    or CheckedIn and CheckedOut
    or Here and Away

    Basically any 2 consistent values that make sense to you.

    Often in a boolean sense, you have a "switch" and it sets the current value to the opposite value.

    For example,

    'switch the value of setting
    ...
    Setting = NOT Setting
    ...

    so when this code is executed, the value of Setting will change.

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

Similar Threads

  1. Clearing a boolean flag
    By accessnewb in forum Programming
    Replies: 14
    Last Post: 08-12-2011, 07:54 AM
  2. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 08:36 PM
  3. Boolean Comparison Not Working
    By Rawb in forum Programming
    Replies: 4
    Last Post: 09-03-2010, 09:17 AM
  4. Unique Values and Boolean Fields
    By Triad in forum Forms
    Replies: 1
    Last Post: 07-15-2010, 06:28 PM
  5. How to query boolean values from table
    By kevdmiller in forum Queries
    Replies: 2
    Last Post: 11-30-2006, 07:41 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