Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access 97 Chart's RowSource

Posted on 1998-08-31
3
349 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

839 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