Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2004
    Posts
    42

    Question Unanswered: Adding values in a form

    I'm going to try to describe what I am trying to accomplish.

    I have a form and on this form I have a [day of the week] and
    a [time spent].

    There can be multiple entries.

    EX:
    [day of the week] [time spent]
    [Monday] [2]
    [Monday] [6]
    [Tuesday] [8]
    [Wednesday] [2]
    [Wednesday] [2]

    And so on.

    I want to sum Monday as a group Tuesday as a group and so on.

    I want to this to happen as entries are entered.

    Any help would be greatly appreciated. Thank You!!

  2. #2
    Join Date
    Apr 2004
    Posts
    42

    Anybody have an answer?

    Anybody have an answer?

    Thanks

  3. #3
    Join Date
    Apr 2004
    Posts
    6

    Re: Anybody have an answer?

    I would write a query that would group by [day of week] and sum the [time spent] column. Then, when the user puts in a new record, have the query run and perform a DoCmd.Requery to update the screen after the record was entered. Here is the SQL I would use....


    SELECT DISTINCTROW [Table1].[dayofweek], Sum([Table1].[timespent]) AS [Sum Of timespent]
    FROM Table1
    GROUP BY [Table1].[dayofweek];


    That will give you the results you want. Then I would build your form based on that query that showed the total for each day.

    Hope that helps...

    Jennifer

  4. #4
    Join Date
    Apr 2004
    Posts
    42
    I let a few things out about my form.

    I want to do this calculation on the subform that has the above data.

    The data is filter by what is in the primary form.

    So it kind of like this.

    [primary form]

    [Name] [Comments] [weekof]

    [Subform]

    [day of week] [project] [time spent]

    ---------------------------------------------
    I currently have a dsum on the mainform and a refresh button that the user has to click on to display current totals after the subform has been changed.

    I want to be able to eliminate the refresh button.


    Thanks

  5. #5
    Join Date
    Apr 2004
    Posts
    6
    Originally posted by BRIANGAMER
    I let a few things out about my form.

    I want to do this calculation on the subform that has the above data.

    The data is filter by what is in the primary form.

    So it kind of like this.

    [primary form]

    [Name] [Comments] [weekof]

    [Subform]

    [day of week] [project] [time spent]

    ---------------------------------------------
    I currently have a dsum on the mainform and a refresh button that the user has to click on to display current totals after the subform has been changed.

    I want to be able to eliminate the refresh button.


    Thanks
    How about instead of a button, you add the code you have behind the refesh button to the 'AfterUpdate' property of the timespent field so when the user enters the timespent, it updates the totals automatically?

    Did I understand your process?

  6. #6
    Join Date
    Apr 2004
    Posts
    42
    You did.

    But when I do that it puts focus on the first record in the timespent subform. So if you click and change timespent and then click to another record to change another record it jumps to the first record. Kind of annoying.

    I would ideally like to do a refresh after I left the subform, but I tried to a procedure from the mainform like on got focus of on dirty. None seem to work. It like I haven't let the mainform.

  7. #7
    Join Date
    Apr 2004
    Posts
    6
    I remember having a similar problem, but cannot remember how I resolved it. I will try to research and think of something.

    Jennifer

Posting Permissions

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