Results 1 to 2 of 2
  1. #1
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10

    DSum problem.

    Hi All,
    I have the following tables and am trying to populate a text box on a form, and store that value in a field TotalSegLengths

    tbl_Segments
    LineNum SegLength


    1 3
    2 9
    2 10

    tbl_Lines
    LineNum TotalSegLengths
    1
    2
    3

    So when I create a new record in tbl_Lines from the form (Form is bound to tbl_Lines) it should query the tbl_Segments, add up the SegLengths for the corresponding LineNum and store that value in TotalSegLengths.

    So for example, with the data as per above, from the form, create a new record with LineNum = 2 and it should display 19 in a text box and store 19 in the TotalSegLengths field.

    I was trying to use DSum in the text box Control Source but was just returning an #Error in the text box.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why save the calculated total? Calculate when needed. Create a query that joins the two table. Make the query an aggregate (GROUP BY) or use report Grouping & Sorting with aggregate calcs functionality.

    Show your DSum expression. Something like:
    = DSum("SegLengths", "tbl_Segments", "LineNum=" & [LineNum])

    Results of textbox ControlSource expression will not automatically save to table. Will need code (I use only VBA) to save the calculated result.
    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. Problem in Query and DSUM function
    By simplefahad2005 in forum Access
    Replies: 3
    Last Post: 07-27-2012, 12:46 AM
  2. Dsum problem help?
    By manos39 in forum Forms
    Replies: 0
    Last Post: 01-12-2012, 05:53 AM
  3. Dsum criteria problem
    By leonhuynh2006 in forum Queries
    Replies: 3
    Last Post: 10-04-2011, 03:18 AM
  4. DSum problem, please help!!
    By Chissy in forum Queries
    Replies: 3
    Last Post: 08-10-2011, 07:39 AM
  5. Replies: 1
    Last Post: 05-05-2010, 01:54 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