Is this a bug?

  • Thread starter Thread starter Paul_D
  • Start date Start date
P

Paul_D

Guest
Hi All,

I have a problem in which I have a form with a number of buttons that are accessing graphical reports in the database. On this form exist a number of criteria such as date ranges, maximum values etc that the reports filter from.

The problem I have is that on some occasions the graphs that comes up is the "sample report" or the report that you see in the design view. It seems that this is not refreshed. If I close the report and open it again it seems to refresh it but it can again happen if you open it again straight after. There does not seem to be any consistency in when this data is updated or when it uses this sample report data.

How can I ensure that the data graphed is live or not?! Is this a bug?

Paul
 
I Found this in another thread..might help answer the Question

I Found this in another thread..might help answer the Question..thanks ro SSmithri for the solution.

ssmithri said:
I am not sure if you are still interested, but, I believe I have found your answer:

http://ourworld.compuserve.com/homepages/attac-cg/ARptTip.htm#GRAPHGEN

Some of the most common questions related to Access reports involve problems with Microsoft Graph or formatting Graph presentations. Here's a few common issues and how to solve them with Visual Basic.

1) Problem: When the report is previewed or printed, Graph doesn't display the proper data from its record source, instead it displays either the data from a prior record or the sample data in the Graph data sheet:

Solution:

Add the following Visual Basic code to the On Print event of the section of the report that contains the Graph object.


On Error Resume Next
Dim objGraph As Object
Set objGraph = Me!TheNameOfYourGraph.Object
objGraph.Refresh
DoEvents
Set objGraph = Nothing
2) The data in the datasheet and sample data shown in Graph in design view is not the data from the record source specified, rather it is some default sample data; so its hard to properly design the graph.
Solution:

Modify the code above adding the following 5th line shown below, preview the report and save it.


On Error Resume Next
Dim objGraph As Object
Set objGraph = Me!TheNameOfYourGraph.Object
objGraph.Refresh
'This will update the data sheet
objGraph.Application.Update
DoEvents
Set objGraph = Nothing

3) Problem: The data table displayed on your Graph will not display the number format you've specified in the Graph's record source (e.g. display only one decimal place by using Format([YourField], "#.0") in the query:

Solution:


Graph sets this formatting in the data sheet view when graph is in design mode; right click on the column that represents the series of data displayed (e.g. column A is series 1, B Series 2 etc.) and choose the "Number format" option.

If Graph still doesn't hold the formatting you desire after setting the format in the datasheet, add code like the following to the On Print event of the same section of the report that contains your Graph:

On Error Resume Next
Dim objGraph As Object
Dim objDS as Object
Set objGraph = Me!TheNameOfYourGraph.Object
Set objDS = objGraph.Application.DataSheet
'Singe decimal place, 200 data points
'Format is the same as Excel VBA
objDS.Range("A1:A200").NumberFormat = "#.0%"
objGraph.Refresh
DoEvents
Set objGraph = Nothing
 
I don't think the code needs to be so complicated. I just requery the chart control in the Format event of the report. The faster your computer, the more likely you are to experience this "out of sync" problem. Requerying forces the control to show the correct data.

Code:
Private Sub FtrProjVer_Format(Cancel As Integer, FormatCount As Integer)
    Me.chrtPlan.Requery
    Me.chrtImplement.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom