Trouble Populating Graph Object's .DataSheet Via VBA

  • Thread starter Thread starter PeteCresswell
  • Start date Start date
P

PeteCresswell

I'm in MS Access VBA, populating an MS Graph 11 object on an Access
form.

Bottom like is that .DataSheet gets loaded if I pause the code and
then resume, but does not get loaded otherwise.


Stepping through the code, it's like the Graph.Datasheet is going
"Poof!" unless I pause the code on or after line 3822 and then resume.


After an unsuccessful load when I right-click the form's Chart object
and select 'Edit' I can see that the datasheet is empty - even though
the code to load it has run without throwing an error and
ChartTitle.Text shows the value I assigned to it.


Been Google-ing for three days; went down to Barns & Noble last nite
in hopes of finding a book on MS Graph... Nada.


This smells like some little quirk in MS Graph - or a touch RCI by
Yours Truly.


One person said he had experienced the same thing, but fixed it by
setting focus on the offending control before the code loaded
..DataSheet. I tried doing that but was not successful.

I've got sample apps that provoke the problem: one in Access 2000 and
another in Access 2003 - So I'm guessing it's not an MS Access bug but
rather some little thing that I'm doing or not doing.

Anybody wants to see a sample (35k zip file) just tell me where to
send/post it.


The Offending Code:
==============================­=====================
3800 If okToProceed = True Then
3810 Set chartRS = curDB().OpenRecordset("qryChar­t",
dbOpenSnapshot,
dbForwardOnly)
3811 With chartRS
3812 If ((.BOF = True) And (.EOF = True)) Then
3813 bugAlert True, "Unexpected empty recordset"
3814 End If
3819 End With


3821 Set fChart = Chart_Open(myTitle)
'
------------------------------­------------------------------­-----------
' As long as I pause the code here, .DataSheet gets loaded.
' Anywhere before this and it does not.


3822 Set myGraphApp = fChart!gphStats.Object.Applica­tion
'
------------------------------­------------------------------­-----------
3823 Set myDataSheet = myGraphApp.DataSheet
3829 Set myChart = myGraphApp.Chart


3840 With myDataSheet
3841 .Cells.Delete
3842 .Cells.ClearContents
3843 .Cells(1, 1) = "Date"
3849 .Cells(1, 2) = myColumnLabel_Value


3850 r = 2
3851 Do Until chartRS.EOF = True
3852 .Cells(r, 1).NumberFormat = "mm-yy"
3853 .Cells(r, 1) = Month(chartRS!StatDate) & "-" &
Year(chartRS!StatDate)
3854 .Cells(r, 2) = Format$(chartRS!StatValue, "#0.000")
3855 chartRS.MoveNext
3856 r = r + 1
3857 Loop
3859 End With


3860 With myChart
3861 .HasTitle = True
3862 .ChartTitle.Text = myTitle
3863 .ChartTitle.Font.Size = 8
3869 .ChartTitle.Font.Bold = False


3870 .Axes(xlValue).HasTitle = False
3871 .Axes(xlValue).TickLabels.Numb­erFormat = "#0.000"
3872 .Axes(xlValue).TickLabels.Font­.Bold = False
3879 .Axes(xlValue).TickLabels.Font­.Size = 8


3880 .Axes(xlCategory).HasTitle = False
3881 .Axes(xlCategory).TickLabels.N­umberFormat = "mm-dd"
3882 .Axes(xlCategory).TickLabels.F­ont.Bold = False
3889 .Axes(xlCategory).MinorTickMar­k = xlTickMarkInside
3897 End With
3998 End If
3999 DoCmd.Hourglass False
==============================­=====================
 
Back
Top