Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2012
    Posts
    6

    Unanswered: sum on subform datasheet to table

    hi, i want to ask
    1 already make textbox name: TbBanyak on subform footer with control source =sum([Jumlah])
    i success display it on mainform with texbox control source =[Jualsubform].[Form]![TbBanyak]

    how to enter/record the result to table record??
    thank you
    Attached Files Attached Files
    Last edited by fenstantra; 08-20-12 at 23:34. Reason: add attachment

  2. #2
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Without knowing the details of what you are trying to accomplish it's hard to answer correctly, but...

    You could create a textbox on the main form that has the destination field in the database as the control source (call it txtTotal for example). Then after you calculate the sum, simply set the value of this text field to the sum on the subform:

    txtTotal.value = [Jualsubform].[Form]![TbBanyak]

    This will save the sum value to whatever database field you have tied txtTotal to. Just make sure you don't overwrite existing value accidentally.

    Steve

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by sps View Post

    ...it's hard to answer correctly, but...
    Actually, it' not hard to answer, correctly, at all! And the answer is...you don't! Storing Calculated Values, in Access, is very, very seldom appropriate! You simply re-calculate your value whenever needed, in Reports, Forms, Queries, etc.

    There are some specialized situations in which Calculated Values can/should be stored, but this certainly isn't one of them.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by Missinglinq View Post
    There are some specialized situations in which Calculated Values can/should be stored, but this certainly isn't one of them.
    I agree that you generally don't save calculated values if these values are coming from the database, but you would if the values are coming from the user and you're only interested in the total.

    From the info provided we don't know what the purpose of the subform is and can't make a definite statement on the correctness of storing calculated values.

    You're right though, I should have put that disclaimer in the answer. Thanks for adding this clarification.

    Steve

  5. #5
    Join Date
    Aug 2012
    Posts
    6
    hi all thank for your reply
    on top post (post no 1) i attach my file, can you please take a look and maybe fix it, thank you
    what i want is the result of the sum can be enter/record to table
    so far i can only display it on form
    thank you

  6. #6
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    To summarize (because linq is right!)... Don't save the totals in your table unless you have a valid reason for doing so. If the data that you are summing still exists in your tables then you should not be storing the sum.

    If you still choose to store this, I gave you on method in my first post. I'm not going to fix your db and send it back, but I'd be happy to help you through it.

    What are you looking for that the first solution didn't meet? What have you done so far?

    Steve

  7. #7
    Join Date
    Aug 2012
    Posts
    6
    Quote Originally Posted by sps View Post
    To summarize (because linq is right!)... Don't save the totals in your table unless you have a valid reason for doing so. If the data that you are summing still exists in your tables then you should not be storing the sum.

    If you still choose to store this, I gave you on method in my first post. I'm not going to fix your db and send it back, but I'd be happy to help you through it.

    What are you looking for that the first solution didn't meet? What have you done so far?
    i try your method again txtTotal.value = [Jualsubform].[Form]![TbBanyak]
    but in after update event
    it now work and now i can save it to table
    thank you so much sps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •