Solved

Access 97 Chart's RowSource

Posted on 1998-08-31
3
346 Views
Last Modified: 2008-02-01
I have a string variable that I need to set as the RowSource of a chart.  How can I do that using VB code in Access?  I've tried   gphProduct.RowSource = str_select and I get an error message.  Any thoughts?
0
Comment
Question by:Magna
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
perove earned 100 total points
ID: 1960877
If this is on a report it cannot be done.
(cant chang graph's row source runtime..)
Is it on a report? I got a workaround if it is..let me know

if it is on a form you can do this:
on the form_open:
 
SQL = "SELECT DISTINCTROW [ko_navn],  blah blah blah"
Me![Field30].RowSource = SQL
Me.Refresh

This works for me, what is the error you gets..?

perove



0
 

Author Comment

by:Magna
ID: 1960878
The chart is on a report.  Can you send me the work-around?  The error message was something to the extent of - You entered an invalid expression for the RowSource of gphProduct or gphProduct does not except the property RowSource -  or something like that.  I have the exact message at work and I am  at home now.
0
 
LVL 9

Expert Comment

by:perove
ID: 1960879
Magna,
Yeah that make sense. I've belied I've read somwhere that you cannot change rowsource on a report runtime.
The workaround is simple it is to instead change the query. So Say you have a report where the graph has rowsource MyStandartGraphQuery

Waht we have to do is to change MyStandartGraphQuery to the real Query:

Here is a sub that changes queries:
Private Sub NK_SkiftQDef(FraQ As String)
'Funksjon that copies a query to MyStandartGraphQuery
 
DoCmd.SetWarnings False
    DoCmd.CopyObject , "MyStandartGraphQuery", A_QUERY, FraQ
DoCmd.SetWarnings True
End Sub


So you must link tha graph to a "standard" query, and before you open the report use this function to copy the query.
If the row source comes from a "user defined" SQL you have to open the query as a querydef, and change it's SQL.
The beuty of this method (it's my own idea actually) is that you can use it in runtime as weel as in MDE.

perove
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

9 Experts available now in Live!

Get 1:1 Help Now