Results 1 to 15 of 15
  1. #1
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47

    Caculation of categorized field's total in form footer

    Hi

    I need help to complete one of my forms.

    In the attachment, I have 5 “Due” fields in the Form Footer to work on, they are :
    [Due30]
    [Due60]
    [Due90]
    [Due120]
    [Due150]

    In the body of the form, I have key data value of [InvDate], [InvoiceNo] & [INVTOTALSUM] to provide info to those “Due” fields.
    The objective of “Due” fields are to find out the sum of [INVTOTALSUM] outstanding in a given period category of 30/60/90/120/150.

    Therefore in all the 5 “Due” fields, what expression should I write to achieve the desired total of [INVTOTALSUM]. Example :


    Due30: IIf(Forms![frm04Soa]![frm04SoaAccs].Form![StatementDate]-[InvDate] < 30, ………..)

    Thanks in advance the help rendered.

    Regards
    Kiang

    Click image for larger version. 

Name:	SoA Error.jpg 
Views:	11 
Size:	116.6 KB 
ID:	20536

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    Sum(IIf(Date()>=InvDate+30, [INVTOTALSUM], 0))
    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.

  3. #3
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Quote Originally Posted by June7 View Post
    Try:

    Sum(IIf(Date()>=InvDate+30, [INVTOTALSUM], 0))

    Thanks.


    Didn't work, it returns with #error.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    AFAIK, it should. I don't know your db so can't debug.
    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.

  5. #5
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    I tried again without correcting the expression, it seems to work with Date() which is current date.

    I want to replace Date() with [StatementDate] which is in an embedded unbound subform. Below was the correction that yield #error :

    Sum(IIf([Forms]![frm04Soa]![frm04SoaAccs].[Form]![StatementDate] =InvDate+30, [INVTOTALSUM], 0))

    Experimentally, I tried putting [Forms]![frm04Soa]![frm04SoaAccs].[Form]![StatementDate] in the control source of field [Due30], it returned with "42,516.00" & when I changed format to Date instead Standard, the date is correct then.

    Any clue of correcting the expression ?

    Thanks !

    Regards
    Kiang

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What do you mean by unbound - where does the subform data come from? If it's the one in the image, looks bound to me.

    I always name subform container different from the object it holds, like ctrDetails.

    Sum(IIf([ctrDetails]![StatementDate] = InvDate + 30, [INVTOTALSUM], 0))

    Shouldn't it be: >= ?
    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.

  7. #7
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Yes, you are right, my typo error. It should be >=

    I'm not sure I'm using the right terminology. What I'm trying to said, the table of the subform has no link to the table of the main form.

  8. #8
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    The name of the subform is frm04SoaAccs

    So I have changed the expr to

    =Sum(IIf([frm04SoaAccs]![StatementDate]>=[InvDate]+30,[INVTOTALSUM],0))

    it returns again to #error

  9. #9
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    I think it has to do with the format of the field.

    When I change the control to

    = [frm04SoaAccs]![StatementDate]

    it returns with 42,156.00

    if I change the format of control to date format, it shows the correct date of [frm04SoaAccs]![StatementDate]

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So the expression is working? If not, try using CDate() function.

    CDate([InvDate])
    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.

  11. #11
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    I tried :

    =Sum(IIf([frm04SoaAccs]![StatementDate]>=CDate([InvDate])+30,[INVTOTALSUM],0))

    And

    =Sum(IIf(CDate([frm04SoaAccs]![StatementDate])>=CDate([InvDate])+30,[INVTOTALSUM],0))

    Both return to #Error

    If

    = CDate([frm04SoaAccs]![StatementDate])

    Or

    = CDate([InvDate])

    result is correct after changing control format from standard to date format.

  12. #12
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Have just tried :

    =[frm04SoaAccs]![StatementDate]-[InvDate]

    The result is correct with 151 days.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This is resolved?
    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.

  14. #14
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Quote Originally Posted by June7 View Post
    This is resolved?
    No

    Regards
    Kiang

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If you want to provide db for analysis, follow instructions at bottom of my post.
    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. Replies: 1
    Last Post: 06-09-2013, 10:40 AM
  2. Replies: 8
    Last Post: 04-29-2013, 12:11 PM
  3. Caculation of total time
    By coliver in forum Access
    Replies: 1
    Last Post: 02-21-2013, 12:01 PM
  4. Replies: 11
    Last Post: 08-27-2012, 11:26 AM
  5. Replies: 26
    Last Post: 11-06-2009, 10:16 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