Msflexgrid add totals

Posted on 2005-03-14
Medium Priority
Last Modified: 2008-03-03
i have a flexgrid that display me some data from a database,
but I want to add a total row that allows me to get the average of each column, how can i insert a row at the bottom of my flexgrid?
Thank you
Question by:Ernesto
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 23

Accepted Solution

gecko_au2003 earned 100 total points
ID: 13539322
Here is a good tutorial :


I think it is something like :


to add a new row, for attaining a running total of a row you could do something like they showed in the example :

There example :

Private Sub cmdAddEntry_Click()
    'add a new entry to our table.
    With Data1.Recordset
        !ArtistName = txtArtistName
        !AlbumTitle = txtAlbumTitle
        !Tracks = txtTrackCount
    End With

    'clear the text fields once the new record is added
    txtArtistName = ""
    txtAlbumTitle = ""
    txtTrackCount = ""
 End Sub

Modifcation of example :

FYI - Insert this code into the click event of the msflexgrid and NOT in a command button. That way it gets the rows values each time you click on a specific row. The coding is something like the below, not sure exactly what it would be because I do not have visual basic installed here and hence I can not test it.

Private Sub cmdAddEntry_Click()
    'add a new entry to our table.
Dim Row1, Row2, Row3,Row4
Dim Total
Dim Average
    With Data1.Recordset
        Row1 = !ArtistName  '<-- assigns each column name to the variable row, make sure you have your column names !
        Row2 =  !AlbumTitle
        Row3 =  !Tracks
        Total = Row1+Row2+Row3
        Average = (Row1+Row2+Row3)/3  '<-- if you can figure out some way of counting the amount
                                                                  'of rows then it will be easier
         .add '<-- just need to figure out how to add each of the variables ( Total and Average)
                       'in to the new row that is created !
    End With
 End Sub


I hope the code above gives you a rough idea of what you need to do to do what you are trying to do !

Other then that maybe wait for another expert to answer or reply :)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question