Results 1 to 6 of 6
  1. #1
    lpkorn423 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    12

    Calculated field with two formulas

    I am using a query to organize some data for invoices. Each record has an Invoice Total and a Paid field.

    The Paid field is a lookup field with 3 options: "Yes", "Discounted", and Null. This describes three situations: yes means they paid in full, discounted means they paid early at a discounted rate, and Null indicates no payment.



    What I would like to do is have a calculated field in the query called TotalPaid. When Paid = Yes, then TotalPaid = InvoiceTotal. When Paid = Discounted, then TotalPaid = InvoiceTotal*.98. When Paid = Null, then TotalPaid = Null (or zero, either option will work)

    Can anyone point me in the right direction? Google and forum searches aren't helping but I'm pretty sure I am using the wrong keywords.
    Last edited by lpkorn423; 12-28-2012 at 10:35 AM. Reason: missing some text

  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
    Check out the Switch() function, or you can nest IIf() functions.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    lpkorn423 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    12
    Thanks again pbaldy!

  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
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    lpkorn423 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    12
    Would this be the correct Switch function?

    InvoiceAmountPaid: Switch([Paid]="Yes",[InvoiceTotal],[Paid]="Discounted",[InvoiceTotal]*0.98,[Paid]=Null,Null)

  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
    If it works, yes. If not, no.

    That said, nothing is ever "=Null". I'd use IsNull() there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Calculated Field
    By MikeDBMan in forum Database Design
    Replies: 1
    Last Post: 03-26-2012, 03:06 PM
  2. Replies: 6
    Last Post: 06-05-2011, 09:30 AM
  3. Calculated Field (if/then) Help
    By agent- in forum Programming
    Replies: 10
    Last Post: 03-30-2011, 05:43 PM
  4. calculated field
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 03-30-2011, 04:29 PM
  5. Calculated field
    By nashr1928 in forum Forms
    Replies: 9
    Last Post: 08-01-2010, 01:59 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