how to set the rowsource in a chart control using visual basic code

  • Thread starter Thread starter ge liu
  • Start date Start date
G

ge liu

Hi,
Could anyone tell me how to using visual basic code to set
the rowsource for a chart control? I tried to use this
type of statement:

me.controls("graph3").rowsource="select Jan03, Feb03,
March03 from sales_table"

But it does not work. Could anyone help? Thanks a
million!

Ge
 
Where (what event) are you running the code? This should work if in the On
Format event of the report section containing the control. You could
simplify this a little with
Me.Graph3.RowSource = "....."
 
Hi, Duane

Thanks for the reply. I was running this code in
Report_Open event. I will try the Detail_Format event.
But I don't see why it should not work for Report_Open
event. As a matter of fact, I try to print out all the
properties of graph3 in the debug window, with this code

Dim prp As Property
For Each prp In Me.Graph3.Properties
Debug.Print Me.Graph3.name; " "; prp.name; "="; prp.Value
Next prp

The output in the debug window I got is:

Graph3 EventProcPrefix=Graph3
Graph3 Name=Graph3
Graph3 ControlType= 113
Graph3 SizeMode= 0
Graph3 OLEClass=Microsoft Graph 2000 Chart
Graph3 Item=
Graph3 DisplayType=False
Graph3 Verb= 0
Graph3 OLEType= 3
Graph3 OLETypeAllowed= 2
Graph3 SourceObject=
Graph3 Class=MSGraph.Chart.8
Graph3 SourceDoc=
Graph3 SourceItem=
Graph3 Visible=True
Graph3 Left= 360
Graph3 Top= 240
Graph3 Width= 12241
Graph3 Height= 7740
Graph3 BackStyle= 1
Graph3 BackColor= 16777215
Graph3 SpecialEffect= 0
Graph3 BorderStyle= 1
Graph3 OldBorderStyle= 1
Graph3 BorderColor= 0
Graph3 BorderWidth= 0
Graph3 BorderLineStyle= 0
Graph3 ShortcutMenuBar=
Graph3 Section= 0
Graph3 Tag=

Notice here the rowsource, rowsourcetype, linkchild, etc.
are not even listed. I don't know why. But if the
rowsource is not even listed, no wonder I can not set its
value. Neverthless, in the online help of MS Access on
RowSource and RowSourceType, it was clearly stated that
RowsSource IS a chart control property and CAN be set by
Visual Basic Code.

Could you give me further guidence?

Best Regards,

Ge
 
Hi, Duane:

Now I tried to run the code in both the Detail_Format and
Detail_Print events, the code:
Me.graph3.RowSource = strSelect
(where strSelect = "select Jan03, Feb03, Mar03 from
sales_table")

give me an error message, says "Run-time error 2191, You
can't set the Rowsource property after printing has
started."

How can I get around it?

Thank

Ge
 
Hi, Duane

I AM able to set the Rowsource property manually from the
property box. When I run in the detail_format or
detail_print events, I got the following error message:

"Run-time error 2191, You can't set the RowSource Property
after printing has started."

how can I get around this?

Best regards,
Ge
 
Back
Top