Results 1 to 9 of 9
  1. #1
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7

    subform form footer text box - total field of amounts using udf is returning error

    I have a subform FacltUndrInvoice. this subform gives me the different charges for rooms used in guest house.

    based on this i have a text field in the subform footer which should give the total of the above charges.

    the text field giving total charge for each entry in the subform uses this code
    Code:
    =nz((Facility_Charges(nz([Fclt]),"Monthly")*nz([txtFcltUsgMnths]))+Facility_Charges(nz([Fclt]),"Weekly")*nz([txtFcltUsgDys])),0)
    where Facility_Charges is a udf extracting charges from a rates table using dlookup function and txtFcltUsgMnths is the total number of months (if any) and txtFcltUsgDys is the total number of days.

    when I use
    Code:
    =Sum(nz((Facility_Charges(nz([Fclt]),"Monthly")*nz([txtFcltUsgMnths]))+Facility_Charges(nz([Fclt]),"Weekly")*nz([txtFcltUsgDys])),0)
    for the total of such charges in the subform footer this gives me an error. I tried all possible ways I could but could not remove the error.

    Please help me out in this, I need an insight desperately. Please let me know if any more information is required.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I think can only use aggregate calc functions on fields, not a UDF. Just as can't use on textbox with an expression. Assuming fields in table called Qty and Units. Now have a textbox calculate: [Qty] * [Units]. Can't do: Sum([textbox name]). Can do: Sum([Qty] * [Units]).
    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
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7
    Quote Originally Posted by June7 View Post
    I think can only use aggregate calc functions on fields, not a UDF. Just as can't use on textbox with an expression. Assuming fields in table called Qty and Units. Now have a textbox calculate: [Qty] * [Units]. Can't do: Sum([textbox name]). Can do: Sum([Qty] * [Units]).

    Thanks for the reply. Does that mean that any udf can't be used in aggregate calculations. If yes, can you please suggest me some way out?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That's exactly what I mean.

    Try doing the record calc in the form's RecordSource query then referencing that constructed field on form in the aggregate calc.
    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
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7
    do you mean I make a calculated field in the form's recordsource query and then use that field as the control source of a text box?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, try that.
    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
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7
    HI
    I had two fields which calculated the total number of months and days between two dates. after I tried your idea I am getting system prompts asking for the number of months and days which actually the calculation should get from the dates supplied in the form itself.

    I must be doing sumthing wrong

  8. #8
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7
    Hi June
    It was my mistake I retained the reference to the text boxes in my formula. Now its working and let me thank you a ton times for that idea.

    Thanks man for the help

  9. #9
    Chandrajit is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    7
    I took out the references to the textboxes and replaced them wiht the calculated fields. Its working

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

Similar Threads

  1. Replies: 2
    Last Post: 02-12-2013, 11:23 AM
  2. Replies: 11
    Last Post: 08-27-2012, 11:26 AM
  3. Blank Field returning #Error
    By imintrouble in forum Access
    Replies: 8
    Last Post: 12-09-2011, 03:00 PM
  4. Replies: 2
    Last Post: 10-19-2010, 11:05 AM
  5. Replies: 26
    Last Post: 11-06-2009, 10:16 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