Ayaz,
Looks like the problem is in your SQL.
When using grouping, you need to perform "aggregate" functions on all the query fields (SUM, MAX etc) that are NOT in the GROUP BY clause.
In your SQL, you have the "SDate" field on its own. If you want to group things by year/month, then use the following SQL:
Code:
Dim sql as String
sql = _
"SELECT Sum([TotalValue] AS [SumOfTotalValue]" & VbCrLf & _
"FROM [Orders]" & VbCrLf & _
"WHERE [Orders].[OrderDate] BETWEEN #" & SelectedYear & "# AND #" & PreviousYear & "#" & VbCrLf & _
"GROUP BY (Year([SDate]), Month([SDate])-1)
With GraphSales
.RowSourceType = "Query"
.RowSource = sql
.Requery
End With
I think that should do the trick. I haven't tested this code though so be warned!
Regards,
Rob