Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,073

    Aggregate query used as ControlSource of text box

    Somewhat continuing from a previous thread regarding the use of the SUM aggregate function. While it functions okay from the design mode of a query, attempting to use the aggregate query as the ControlSource of an unbound text box has a problem I can't find. Note in the image below that the "Continuous" form "Portfolio" has as its RecordSource a query that includes ALL fields of the Portfolio table.

    Click image for larger version. 

Name:	ControlSource.jpg 
Views:	12 
Size:	157.2 KB 
ID:	19116



    Is this really the best approach?

  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,641
    You can't have SQL in the control source. Nearest equivalent would be a DSum() using the full form reference.

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,073
    Trying to follow Baldy's suggestion, I'm still getting more-or-less the same errors when I attempt to use DSUM.

    Click image for larger version. 

Name:	DSUM.jpg 
Views:	11 
Size:	116.7 KB 
ID:	19117

  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,641
    Check the link again; concatenate the form value, and I'd use the full reference.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,073
    Sorry Paul, you've lost me. How do the DLookup samples at the link you sent relate to the use of the DSUM function?

  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,641
    From the link:

    Note that the same logic applies to most Domain Aggregate Functions (DMax, DMin etc.)

    That includes DSum().
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,073
    =DSum("[Shares]","Ledgers","[InvstID] = " & forms!Portfolio!InvstID)

    YEAH!!!

    Thanks,
    Bill

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help Bill!
    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. DLookup as ControlSource for a text box?
    By GraeagleBill in forum Forms
    Replies: 4
    Last Post: 03-29-2013, 05:09 PM
  2. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  3. Replies: 23
    Last Post: 02-07-2013, 06:42 PM
  4. Aggregate Query - Need Help
    By nerd__ in forum Queries
    Replies: 5
    Last Post: 11-19-2012, 03:34 PM
  5. Dynamic Text Box ControlSource from multiple tables
    By cjtezak in forum Programming
    Replies: 2
    Last Post: 06-20-2012, 10:07 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