Results 1 to 4 of 4
  1. #1
    mike_980 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    58

    query - if is true then add 30?

    Hi guys, probably an easy one today but not something ive ever done before!



    Basically what I need making into an expression is "If shallow_soil = true then N_max + 30, If Shallow_soil = false then leave N_max alone"


    Click image for larger version. 

Name:	Untitled.png 
Views:	13 
Size:	140.0 KB 
ID:	14411

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You have pretty much already written it yourself.
    What is the data type of Shallow_soil?
    Is it Boolean or String?

    If it is Boolean, then:
    Code:
    MyCalc:IIF([Shallow_soil]=True,[N_max] + 30, [N_max])
    If it is String, then:
    Code:
    MyCalc:IIF([Shallow_soil]="True",[N_max] + 30, [N_max])

  3. #3
    mike_980 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    58
    Works perfectly thanks alot! I knew the theory on how it would work but I couldn't get it to work for some reason, I don't think I had the brackets quite right (I can never get them right!)

    Thanks again.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If you field names do not have spaces in them, you usually do not need the square brackets. But it never hurts to add them.

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

Similar Threads

  1. A TRUE Keyword Search
    By Meep in forum Queries
    Replies: 72
    Last Post: 05-13-2013, 06:45 PM
  2. If value is true... Cannot be used.
    By DTK0902 in forum Access
    Replies: 6
    Last Post: 11-27-2012, 07:49 AM
  3. Yes/No True/False
    By DSTR3 in forum Access
    Replies: 5
    Last Post: 12-04-2010, 05:56 PM
  4. If any of the following are true
    By Steven.Allman in forum Queries
    Replies: 7
    Last Post: 08-30-2010, 06:10 AM
  5. True or false
    By tleec in forum Queries
    Replies: 1
    Last Post: 02-01-2008, 10:41 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