?
Solved

Msflexgrid add totals

Posted on 2005-03-14
1
Medium Priority
?
238 Views
Last Modified: 2008-03-03
Hi.
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
0
Comment
Question by:Ernesto
[X]
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

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

http://pages.cpsc.ucalgary.ca/~saul/vb_examples/tutorial2/

I think it is something like :

flexgrid.AddNew

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
        .AddNew
        !ArtistName = txtArtistName
        !AlbumTitle = txtAlbumTitle
        !Tracks = txtTrackCount
        .Update
    End With
    Data1.Refresh

    '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 !
        .Update
    End With
    Data1.Refresh
 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 :)
0

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