Results 1 to 12 of 12
  1. #1
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46

    Calculation in a group footer.

    I need a text box that is in a group footer that will call a Function named fSAR. I would like it to be global because I will use it in other reports. The calculation will be based on three records in my [Analysis] table:



    I need to use the three entries when [AnalysisName] = 73,74, and 75.

    A simplified version of the functions is:

    fSAR = [AnalysisName]=75 / SQR(([AnalysisName]= 73 + [AnalysisName] = 74)/2) '75=the result for Sodium, 74=the result for Magnesium, 73=the restult for Calcium

    What do I have to declare in the Function line and how?

  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,521
    I'm not at all clear on what you're trying to achieve. Does this get you started?

    http://www.baldyweb.com/Function.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    The equation I need to perform will have 3 variables in it:

    1 = the analysis result for Calcium
    2 = the analysis result for Magnesium
    3 = the analysis result for Sodium

    Because I tables are Master/Child ([tblAnalysis]/[tblParameter]) all three of the above variables (Calcium, Magnesium, and Sodium) come from the field in [tblAnalysis]![AnalysisResultNumeric]. I know which analysis they are from the table [tblParameter] which is linked to to [tblAnalysis] through a long integer field named [tblAnalysis]![AnalysisName]. So to make the calculation I need to call the result for the value in [AnalysisResultNumeric] for three records when :

    [AnalysisName] = 73 'which tells me the parameter is 'Calcium'
    [AnalysisName] = 74 'which tells me the parameter is 'Magnesium'
    [AnalysisName] = 75 'which tells me the parameter is 'Sodium'

  4. #4
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    I can do the math programing so here is the equation simplified:

    fSAR = {Result for Sodium}/({Result for Calcium} + {Result for Magnesium})

    All three of the variables I need come from three records from same field in the table [tblAnalysis] called [AnalysisResultNumeric] and are differentiated by the field in [tlbAnalysis] called [AnalysisName] which is a field linking to the table [tblParameter] which gives me all the relevant information for that parameter. (Sodium, Calcium, Magnesium, ect.)

  5. #5
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    It is basically making a calculation from 3 records of the same field and there will be many other records in the report. I need to pick the records that give the result for Calcium, Magnesium, and Sodium.

  6. #6
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    Once again, how do I choose three records out of a report group to make a calculation in the group footer?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm sorry, I'm not really understanding the data structure and such. All I can say is you'd have to have some criteria that would let you identify the three records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    Here are the detail lines for the report:

    AnalysisName Result
    pH 7.0
    Conductivity 1.56
    Calcium 78
    Magnesium 14
    Sodium 53

    Potassium 7
    Nitrate 0.1
    Sulfate 34
    Chloride 67
    group footer
    SAR 8.67 'SAR is a calculation based on the three bold results above.

    I need to extract the three result values for Calcium, Magnesium, and Sodium each separate detail lines that use the same field in the underlying table and are differentiated by the AnalysisName field in the same table.

  9. #9
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    oops the Result values didn't space out porperly..

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are these different fields (columns) in the same record (row) or are they in different records?

  11. #11
    stupesek is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    46
    The AnalysisName is a field in a table that Identifies what parameter is in the Result field in the same table. In my above example the numbers were supposed to be aligned under a Result column. Evidently the posting took out the spaces I added.

    Anyhow each row is a record in a table, each column is a field in the same table.

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So this is a Report correct? Are you aware that you can have invisible controls on your report? Maybe labeled: txtSodium, txtMagnesium, txtCalcium. Assuming the report looks pretty much as you have described then there would probably be these three invisible controls on each line. Their ControlSource for txtCalcium would be set to something like: IIF([AnalysisName] = "Calcium", [Result],0) and so on. Then summing them in the GroupFooter would give you the values you need for your calculation. Make sense?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Page Footer
    By jamil_kwi in forum Access
    Replies: 1
    Last Post: 05-31-2010, 04:02 AM
  2. Trouble Summarizing in Group Footer
    By Millerguitarworks in forum Reports
    Replies: 2
    Last Post: 12-07-2009, 06:06 AM
  3. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 AM
  4. Replies: 0
    Last Post: 02-11-2009, 06:43 PM
  5. Totaling a value in group footer...
    By hodgy20 in forum Reports
    Replies: 0
    Last Post: 11-14-2008, 08:28 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