I've used the following code to fill the datasheet behind a graph in a report with the result of a dynamic sql-query.

Problem is that it works fine in access97 but when converted to access2000 it leaves a report with a totaly blank graph. I don't encounter any errors or problems with the code. Does anybody have any ideas of why. Or another method to do what I need in access 2000?


Private Sub Detalj_Format(Cancel As Integer, FormatCount As Integer)

Dim rs As DAO.Recordset
Dim strsql As String

strsql = Forms!frmbehandlingsmatninghistorisk.rows 'Linking to sql-query in form

Set rs = CurrentDb.OpenRecordset(strsql)
'Now pass 2 objects to a sub
FillDataSheet Me.Diagram2.Object, rs

Set rs = Nothing

End Sub

Public Sub FillDataSheet(oGraph As Object, rs As DAO.Recordset)

'This will fill the datasheet of the Chart 'with the data in the recordset

Dim oSheet As Object 'Graph.DataSheet

Dim r As Integer 'row counter
Dim c As Integer 'column counter

Set oSheet = oGraph.Application.DataSheet

'clear old data
oSheet.Cells.ClearContents '1st Row Field Names = Legend entries
For c = 1 To rs.Fields.Count
oSheet.Cells(1, c) = rs(c - 1).Name

'now data rows
r = 2
Do Until rs.EOF
For c = 1 To rs.Fields.Count
If IsNull(rs(c - 1).Value) Then
oSheet.Cells(r, c) = rs(c - 1).Value
End If
r = r + 1
Set oSheet = Nothing

End Sub