Results 1 to 6 of 6
  1. #1
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212

    Workaround needed for adding calculated fields in a query

    I have a field used in data entry together with a flag. I put the value in this field into 3 other fields depending on the value in the flag field. I am using an IIF statement in the query expression to do this. The calculated fields end up as three columns in a report. I have been unable to add these fields together so that I can total them in the report. I cannot use Sum because each field is individual, they are not a column in a query. I have tried creating a column in the query which strings the IIF statements with a + in between, but this does not work.

    IIf statement

    poc816b: (Nz(IIf([816b]="borrower",Format([L816d],'$#,#00.00'),"")))
    poc816s: (Nz(IIf([816b]="seller",Format([L816d],'$#,#00.00'),"")))
    poc816o: (Nz(IIf([816b]="other",Format([L816d],'$#,#00.00'),"")))

  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,640
    Have you tried having these fields return numbers instead of strings (including a zero instead of "")? That should allow you to sum them on a report, or add them up in the query with +. Format them on the form or report, not in the expression.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Hi Paul, Thanks, that works for the query. It leaves me with $0.00 in the report where I would prefer to have blanks. Do you have a suggestion for that? This is the finishing touch to a week of work, so it would be nice to nail it down. Appreciate your help.

  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,640
    You can use the Format property of the textbox to hide zeros (look for the 4-part syntax).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Hi Paul, I found the four part syntax, I had to change the "zero" to "" and it worked. Many thanks. $#,##0.00[Green];($#,##0.00)[Red];"Zero";"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,640
    Happy to help!
    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. Adding two calculated fields into a third
    By bobbynogs in forum Reports
    Replies: 3
    Last Post: 07-11-2014, 06:20 AM
  2. Query Design - Calculated Fields
    By roarcrm in forum Queries
    Replies: 6
    Last Post: 06-26-2014, 12:14 PM
  3. Replies: 12
    Last Post: 10-01-2013, 12:59 PM
  4. Adding calculated fields
    By Hulkdog in forum Access
    Replies: 12
    Last Post: 02-06-2012, 03:46 PM
  5. Replies: 2
    Last Post: 12-03-2010, 09:33 AM

Tags for this Thread

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