Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running Product (Not Sum) (Acc2002 (as 2k))

    Hi All,
    I've run across numerous examples of how to stick a Running Total into the footer of a form. No problem, done that plenty o' times.
    But, how can (or can it) a Running Product be placed into a textbox on a subform footer (or header, as the footer is 'hidden' until it is scrolled to), with the subform being a continuous form and the product coming from the "same" textbox (field)?
    <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>
    Thank You.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Running Product (Not Sum) (Acc2002 (as 2k))

    I have never done this, but what I would try would be to create custom function along these lines.

    Make a recordset of the records in the subform, then loop thorugh each record multiplying the relevant fields together and returning the result.
    Regards
    John



  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Product (Not Sum) (Acc2002 (as 2k))

    Hi John and Thank You
    Sorry it took so long to answer this but I've been traveling all day and was just able to try your suggestion. Thanks for the nudge in the right direction. Here's what I did:

    Dim db As Database
    Dim rst As Recordset
    Dim dblProduct As Double

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("qryProbeData2point1")
    dblProduct = 1

    With rst
    Do Until .EOF
    dblProduct = dblProduct * Nz(rst!RoundPI, 1)
    .MoveNext
    Loop
    End With

    Me!dblCummPI = dblProduct

    where RoundPI is the field I'm multiplying against itself and dblCummPI is the unbound field, in the footer, for the "Running Product". This is a statistical probability so the 1 is an identity.

    Thanks again.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

Posting Permissions

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