Results 1 to 5 of 5
  1. #1
    Alinchains is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    2

    If statement

    Here is what I am struggling with. I have a database where I need multiple If statements. but here is an example of what I am trying to do.

    If [Activity AU Frequency] = "Monthly" and [Control AU Frequency] = "Annual or less" and [Monitoring Tool AU Frequency] = "Annual or less" then "Fail"


    If [Activity AU Frequency] = "Daily" and [Control AU Frequency] = "Monthly" and [Monitoring Tool AU Frequency] = "quarterly" then "Pass"

    And so on for each possible scenario.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    use a giant case statment (below), or if you can, use a table to put these in.


    select case true
    case [Activity AU Frequency] = "Monthly" and [Control AU Frequency] = "Annual or less" and [Monitoring Tool AU Frequency] = "Annual or less"
    msgbox "Fail"


    case [Activity AU Frequency] = "Daily" and [Control AU Frequency] = "Monthly" and [Monitoring Tool AU Frequency] = "quarterly" then
    msgbox "Pass"

    end select

  3. #3
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    You have an errant "then" Ranman left over from your copy and paste.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    Alinchains is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2020
    Posts
    2
    Thats awesome. Sorry I wasn't clear enough. I need the query to update another field [Pass/Fail] as Pass/Fail

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Insert your update code where Ranman has the msgbox statement.

    Code:
    select case true
    
    case [Activity AU Frequency] = "Monthly" and [Control AU Frequency] = "Annual or less" and [Monitoring Tool AU Frequency] = "Annual or less"
    
    'update code here
    
    case [Activity AU Frequency] = "Daily" and [Control AU Frequency] = "Monthly" and [Monitoring Tool AU Frequency] = "quarterly" 
    
    'update code here
    
    end select
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  2. use if statement or something else
    By billcar2006 in forum Access
    Replies: 3
    Last Post: 03-09-2015, 03:34 PM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. If Statement
    By ajolson1964 in forum Access
    Replies: 1
    Last Post: 05-11-2011, 07:51 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