Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

showing a graph b/w the months

hi all...............
in my proj i am using a mschart ....
now what i want is i want to display the graph amount v/s months
I did the graph which shows date v/s amount its working good...
i used the sql query for that.... for month also i wrotequery but its not working properly....

what i need is it should add all the amounts which are entered in the particular dates on that month then it show the graph...

plz if u know that send me the answer

and my code is like this, this is for dates.......


Private Sub cmdGraph_Click()

Dim chrtArray()

'//
' Close the record set if open
'\
If rst.State <> adStateClosed Then
rst.Close
End If



With Form1
Set cmd.ActiveConnection = cnn
cmd.CommandText = "SELECT Table1.TodayDate, Table1.Amount, Table1.Description" _
& " FROM Table1" _
& " Where Table1.TodayDate >= #" & txtFromDate.Text & "#" _
& " And Table1.TodayDate <= #" & txtToDate.Text & "#" _
& " ORDER BY Table1.TodayDate"

rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenStatic, adLockBatchOptimistic

If rst.RecordCount = 0 Then
MsgBox "site does not have any availability data"
Exit Sub
End If
'//
' Give the record set to the gird for display
'\
Set grdMonData.Recordset = rst
grdMonData.Refresh
'//
' C H A R T
'
' Dynamic 2-dimensional array to store series
' The first index (x) is the total number of series
' The second index will store the Date(1) and its end-to-end time(2).
' x-axis value in the 1st slot (i.e. chrtArray(x,1)
' y-axis value in the 2nd slot (i.e. chrtArray(x,2)
'
'\
ReDim chrtArray(1 To rst.RecordCount, 1 To 2)

.MSChart1.ShowLegend = True
.MSChart1.ChartType = VtChChartType2dBar
'//
' Chart Title centered on top
'\
.MSChart1.Title.Text = " Expence Details"
'//
' Chart X and Y axis titles
'\
.MSChart1.Plot.Axis(VtChAxisIdX).AxisTitle.Text = "Date"
.MSChart1.Plot.Axis(VtChAxisIdY).AxisTitle.Text = "Amount"
'//
' Chart Foot note
'\
'MSChart1.FootnoteText = "some note"
'//
' Load the array with data
'\
For X = 1 To rst.RecordCount
chrtArray(X, 1) = rst!TodayDate
chrtArray(X, 2) = rst!Amount

rst.MoveNext
Next X
'//
' Attach the array of data to MS-CHART
' setup the column lable (the project id)
'\

.MSChart1.ChartData = chrtArray
.MSChart1.ColumnCount = 1
.MSChart1.ColumnLabelCount = 1
.MSChart1.Column = 1
.MSChart1.Refresh
End With

End Sub




Comments

  • dokken2dokken2 Member Posts: 532
    : hi all...............
    : in my proj i am using a mschart ....
    : now what i want is i want to display the graph amount v/s months
    : I did the graph which shows date v/s amount its working good...
    : i used the sql query for that.... for month also i wrotequery but
    : its not working properly....
    :
    : what i need is it should add all the amounts which are entered in
    : the particular dates on that month then it show the graph...
    :
    : plz if u know that send me the answer



    think you need to use an aggregate query/sql. first, select the month from the date and sum the values, then groupby the month. that would give totals by each month

    SELECT Month([date1]) AS MyMonth, Sum(Table1.amount) AS SumOfamount
    FROM Table1
    GROUP BY Month([date1]);
  • RekhascRekhasc Member Posts: 7
    : : hi all...............
    : : in my proj i am using a mschart ....
    : : now what i want is i want to display the graph amount v/s months
    : : I did the graph which shows date v/s amount its working good...
    : : i used the sql query for that.... for month also i wrotequery but
    : : its not working properly....
    : :
    : : what i need is it should add all the amounts which are entered in
    : : the particular dates on that month then it show the graph...
    : :
    : : plz if u know that send me the answer
    :
    :
    :
    : think you need to use an aggregate query/sql. first, select the
    : month from the date and sum the values, then groupby the month.
    : that would give totals by each month
    :
    : SELECT Month([date1]) AS MyMonth, Sum(Table1.amount) AS SumOfamount
    : FROM Table1
    : GROUP BY Month([date1]);
    :


    Thank you very much
Sign In or Register to comment.