Solved

Urgent: Unable to change the RowSource property in a chart object through macro ot code.

Posted on 2002-04-18
2
587 Views
Last Modified: 2008-07-07
Hi everybody,

In my database, I produce a report with charts. These charts are not to be based on records in a table but on calculated controls on the report itself.
To do that, I want to be able to change the rowsource property through either a macro or some code started when the report is open. (note: the Rowsourcetype is set to Value List and column count to 4.) It seems simple yet it does not work!

Both when I use a macro (SetValue) or the code below, I receive the following error message: “Run-time error ‘2455’: you entered an expression that has an invalid reference to the property RowSource.”

However, when I use the same code in a form, it works fine. Should I understand that what is true for a form in not true for a report. Or is there a way to solve this issue?

Thanks.

Arnaud


Private Sub Report_Open(Cancel As Integer)
    Dim Chartsource As String
    Chartsource = "Road ; Paved ; Maintainable ;  Maintained ;  Country ; .95 ; .50 ; .25 ; Region ; .10 ; .45 ; .35"
    Me!Network_condition_graph.RowSource = Chartsource
End Sub
0
Comment
Question by:desmarch
2 Comments
 
LVL 2

Accepted Solution

by:
xtrahands earned 100 total points
ID: 6951774
I'm pretty sure that the rowsource cannot be changed at runtime.  Instead you need to open the report in design view change the rowsource and then open the report in preview/print mode.  E.g.

Sub chnggraph()

Dim Chartsource As String
Dim rpt As Report

 
DoCmd.OpenReport "Report1", acViewDesign
Set rpt = Reports("Report1")
Chartsource = "Road ; Paved ; Maintainable ;  Maintained ;  Country ; 0.95 ; .50 ; .25 ; Region ; .10 ; .45 ; .35"
rpt!Network_condition_graph.RowSource = Chartsource

Set rpt = Nothing
DoCmd.OpenReport "Report1", acViewPreview

End Sub
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7119830
for desmarch

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now