Results 1 to 4 of 4
  1. #1
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154

    IIF function for 2 criteria

    Dear all

    I need some help for the IIF statement


    I have a sale record that collected for July and August

    I have decided to offer an Early bird offer to those who purchase in July

    I have a table recorded the following

    Month | client | Purchase (1=Yes/0 =No)
    1 July | Eric | 1
    5 July | Bertha |1
    3 Aug | Paul |1



    I have already applied Priceurchase=1,HK$100,0)

    But how i can make that like for those who purchase before 1 August Price = Price = 95?

    Thanks
    Eric

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    1.
    the better answer is , this should be done via the query and the tInventory table and a tDiscount table.
    where the tDiscount value is given if date < 8/1/yy ,

    ITEMID, PRICE, DISCOUNTPRICE
    123, 100, 95

    then the query reads the tDiscount date, and converts tInventory .price to the tInventory .DISCOUNTPRICE.

    2.
    THE EASIER WAY :
    run an update AT the purchase, (or some point)
    to modify the purchase table to the discount price. UPDATE tPurchase set [price]=95 where [PurchDate]<#8/1/17#
    no IIF needed.

    3. But to use IIF:
    IIF([PurchDate]<#8/1/17#,100,95)

  3. #3
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June

    I perfect the option of
    3. But to use IIF:
    IIF([PurchDate]<#8/1/17#,100,95)


    My structure is

    [purchasedate]
    [item1] = input for user is 1 or null
    [item2]
    = input for user is 1 or null

    So if i use your suggestion

    IIF([PurchDate]<#8/1/17#,[item1]=1, 100,95)??

    Eric




  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,957
    Month is a reserved word. Should not use reserved words as names for anything.

    You are saving month name in field? Apply discount only to month of July - not Jan thru Jun?

    95 and 100 are the only prices for every purchase?

    Exactly what is table structure? Posts 1 and 3 seem contradictory. Are there actually 2 tables involved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Dlookup criteria with OR function
    By Bkper087 in forum Access
    Replies: 1
    Last Post: 03-27-2017, 07:22 PM
  2. AddNew Function, but with Criteria?
    By mrmims in forum Modules
    Replies: 2
    Last Post: 03-20-2017, 05:44 PM
  3. VBA function result as query criteria
    By lefty2cox in forum Programming
    Replies: 13
    Last Post: 12-22-2015, 10:41 AM
  4. Use Criteria Count, IF Function, or Other
    By andydavidbrown in forum Queries
    Replies: 2
    Last Post: 08-26-2015, 12:30 PM
  5. Created function as criteria
    By BillMc in forum Queries
    Replies: 5
    Last Post: 08-09-2011, 03:37 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