Referencing a TChart in code

TeeChart for ActiveX, COM and ASP
Post Reply
DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Referencing a TChart in code

Post by DJ200 » Tue Jun 10, 2008 11:13 am

Hello Steema support.

I have a new problem.
I have an Active Report containing 11 TCharts..1 - 11.

The reference to one of my charts needs to be set at run time because, depending upon which tests are in a survey, TChart4 (for example) may contain the graphed data for a certain test (Test X), or, if other tests are present, then TChart6 may have to contain the graphed data for Test X.

What I want to do is to set a variable called TChart, and then assign a design time TChart to that variable, ie:

Private Sub FVIII_Graphs()

DIM TCHART AS TCHART '*Create the varaible to assigen the TChart name to

Set rsGeneric = Nothing
Reg = False

Set rsGeneric = Graphs.Get_Factor_Graph_Data(Survey, "Arch_Graph_Data_FVIII")

If rsGeneric.RecordCount > 0 Then

Select Case Group
Case Is = 1
Set TChart = TChart6
Case Is = 2
Select Case ExtraFactor
Case Is = "FII", "FV", "FVII"
Set TChart = TChart7
Case Else
Set TChart = TChart6
End Select
End Select

TChart.Header.Text.Text = "FVIII Total data Plot"
TChart.Axis.Bottom.Title.Caption = "FVIII"
TChart.Series(0).DataSource = "" '*Clear out any old datasource

If Reg = True Then

With TChart.Series(0)
.Color = vbRed
.asBar.MultiBar = mbStacked
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(2).Name '*The Y Axis (Total)
.LabelsSource = rsGeneric.Fields(1).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each pint
.ShowInLegend = False '*Don't show the Series title
End With
End If

' End If

Reg = False
Set rsGeneric = Nothing

End Sub

Is there a way of doing this, and what is the syntax as the above produces a Type error.

Thank you

Regards

David

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jun 18, 2008 9:55 am

Hi David,

You can try using something like this:

Code: Select all

Private WithEvents TChart1 As TeeChart.TChart

Private Sub Form_Load()
   Set TChart1 = CreateObject("TeeChart.Tchart.6")  ‘ for activex v6
End sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply