Results 1 to 7 of 7
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Subform footer function

    I have a subform that displays dates and points (numbers) fields. I want the textbox in the form footer to display only the total points of the records that are 1 year or newer, however still showing all of the records in the detail section. The textbox control source is;



    =Sum(IIf(Date()-[txtPtDate]<365,[Pts],0))

    I have tried the syntax a couple different ways, but still get an error in the textbox in form view. I'm hoping it's something simple, but haven't figured it out yet. Can someone please help?

    Thank you in advance.

  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,521
    If either the date or the points are calculated controls in the detail section, you can't sum it (I think...for sure the points, not for sure the date). Also make sure you're in the form footer, not the page footer.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    instead of txtPtDate, use the name of the field (i.e. the controlsource of txtPtDate)

    Also is Pts a calculated value in the form? e.g. Qty*0.01

    if so you need to use that calculation instead of Pts in your sum

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Neither of the fields is calculated, both are stored in the table. And the textbox I'm working on is in the form footer, not the page footer.
    The Record Source of the subform is

    SELECT [qryPts].[PtDate], [qryPts].[PtPoints] FROM qryPts WHERE [qryPts]![PtPermit] = [Forms]![frmPermit]![Permit];

    This part is working well in the detail section, as it is only showing records that match the permit number. But is it also the root of the problem since the record source is not a direct reference to a table/query? Or is the "Date()" part not understood in this use to represent todays date?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    Query for RecordSource should be just fine.
    Use of Date() should also work.

    Did you try suggestion to use field name instead of textbox name?

    Field is PtPoints so what is Pts?

    Could calculate in query: IIf(Date()-PTDate<365, [PtPoints], 0) AS NewPts

    Then in textbox: =Sum(NewPts)
    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.

  6. #6
    Join Date
    Apr 2017
    Posts
    1,679
    In form Footer, there is is a functionality to display the total of any field in form's Detail section (grouping). To get total for last year only, instead table use a query as source, and add there a calculated field, which returns Qty for records of last year, and 0 otherwise (like SELECT *, Qty*Iif(Date()-PtDate > 365, 0, Qty) As LastYearQty FROM YourTable). In footer, you use grouping on this calculated field.

  7. #7
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Thanks June7, adding the field to the query did all the work for me. So simple, but out of my reach.

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

Similar Threads

  1. DLookUp Function in Report Footer
    By craigger01 in forum Reports
    Replies: 12
    Last Post: 09-28-2018, 12:11 PM
  2. Replies: 3
    Last Post: 06-29-2017, 03:02 PM
  3. IIf Function in Report Footer
    By Ron H. in forum Access
    Replies: 3
    Last Post: 12-21-2013, 04:05 AM
  4. Replies: 7
    Last Post: 10-04-2013, 11:45 AM
  5. Subform Footer Calculation
    By bsc0617 in forum Forms
    Replies: 21
    Last Post: 08-29-2013, 02:28 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