Results 1 to 3 of 3
  1. #1
    mfred is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    2

    Query for 1 or 0 in one field according to positive or negative numbers in another field


    I need to create a query in Microsoft Access to enter 1 or 0 in a field based on whether numbers in another field is positive or negative. Here are the details.

    1 entered in a "late" field if "TotalHoursAheadOrBehindScedule" field has a positive number
    0 entered in a "late" field if "TotalHoursAheadOrBehindScedule" field has a negative number

    This is a bit outside of my query knowledge. Can anyone advise with inforamtion for writing such a field query?

    Thanks in advance.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if this is in a query

    Late: iif(totalhoursaheadorbehindschedule >0, 1, iif(totalhoursaheadorbehindschedule <0, 0, 99))

    you don't account for totalhoursaheadorbehindschedule being zero in your original post so I'm having it be 99, modify at your discretion.

    If it's on a form the controls source of the text box would be:

    =iif(totalhoursaheadorbehindschedule >0, 1, iif(totalhoursaheadorbehindschedule <0, 0, 99))

  3. #3
    mfred is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    2
    It is a query. Thank you very much for the help.

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

Similar Threads

  1. Replies: 1
    Last Post: 10-22-2014, 01:28 PM
  2. Replies: 7
    Last Post: 06-29-2013, 06:01 PM
  3. Replies: 3
    Last Post: 06-01-2013, 10:56 PM
  4. Replies: 7
    Last Post: 09-16-2011, 01:39 PM
  5. Replies: 2
    Last Post: 01-13-2010, 05:29 AM

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