Results 1 to 15 of 15
  1. #1
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9

    if this than that OR if this then that

    I have two statements that I need to somehow merge together in the same line:

    statement #1 is =IIf([type of award]="NA",60,Null)
    statement #2 is =IIf([type of award]="NC",90,Null)

    So basically looking for something along the lines of this:

    =IIf([type of award]="NA",60,Null) OR =IIf([type of award]="NC",90,Null)

    Some background if needed:
    [type of award] is a combo box
    60 and 90 will be used for how many days prior to date entered in another box

    both statements work off the same combo box when separated, but the outcomes are in two separate fields instead of one (like I want when the statements are merged)


    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I suspect:

    =IIf([type of award]="NA",60, IIf([type of award]="NC",90,Null))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    perfect! thanks for the help. works like a charm

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    So now my only problem is getting that 60 or 90 to subtract from a date that the user will enter, to determine a "due date" I got it to work in the form, but that's all. Under the query that was created all I get for that expression is #Error, same with when the report is ran.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What's the SQL of the query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    SELECT Table1.[type of award], Table1.[date due to admin], Table1.[retirement/transfer date], Table1.[NUMBER DAYS DUE], Table1.[date due], IIf([type of award]="NC",90,IIf([type of award]="NA",60,Null)) AS Expr1, DateAdd("d",-[NUMBER DAYS DUE],[retirement/transfer date]) AS Expr2, [date due to admin] AS Expr3
    FROM Table1;

    I hope that is what you are meaning, I don't use Access in this way. I know the basics and usually just pick and play until it works.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes, that's what I meant, but I don't see why it would error offhand. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    it says it's to big even after compression, weird as there is nothing even in it.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try doing a compact/repair before zipping.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    Had to recreate it, wouldn't let me do that after I compressed it through windows
    Attached Files Attached Files

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The field with the error is this one:

    Expr2: DateAdd("d",-[NUMBER DAYS DUE],[retirement/transfer date])

    And it errors because there is no value in the [NUMBER DAYS DUE] field. You'll find the symbols and spaces in your field names aren't worth the bother in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I should have added that you can suppress the error:

    DateAdd("d",-Nz([NUMBER DAYS DUE],0),[retirement/transfer date])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    dachap1983 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    9
    ok, I used what you said and came up with this for the query (it subtracts the 60/90 from the retirement/transfer date):

    Expr2: DateAdd("d",-[Expr1],[retirement/transfer date])

    everything is good now (I hope, lol). thanks for taking the time to help

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

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