Graph Problem in Access (1 Viewer)

keiths

Registered User.
Local time
Today, 14:31
Joined
Feb 10, 2005
Messages
28
I have an x-y graph on a form that gets its data from a query. The query pulls five records of data from a table. So there are five data points I want to have displayd on the graph. I got the graph to work properly except it only displays four points! The first data point is not displaying.
I tried to set the datasheet in the graph to "ignore" the first row, as I noticed immediately that it does not have a number reference....I am assuming that is the problem.
Is there a method to resolve this easily? I assume that it must be done with vba. My data is used by the graph in two columns...first column is the X value, second column is the Y value.
 
Last edited:

Oldsoftboss

AWF VIP
Local time
Tomorrow, 07:31
Joined
Oct 28, 2001
Messages
2,504
Graphs are a pain in the ?*#) with Access. Perseverance is about the only way.
 

keiths

Registered User.
Local time
Today, 14:31
Joined
Feb 10, 2005
Messages
28
Graph Problem Resolved - sort of

I reviewed some hints and code I found on different sites. Here is what I eventually came up with for my problem. :cool:

Private Sub Detail_Click()

Dim oGraph As Object
Dim oDataSheet As Object
Dim db as Database
Dim rs as Recordset
Dim RowCnt as Long

' Tell VBA that graph to use is named Rika and on the form
Set oGraph = Me!Rika.Object
Set oDatasheet = oGraph.Application.DataSheet
Set db = CurrentDb

' query Rika1 is data to be used for the chart
Set rs = db.OpenRecordset("Rika1")

' Start data in second row of datasheet because first row is used by msGraph
' Still not sure why, or if it can be changed
RowCnt = 2

With rs
Do While not .EOF
' Place data in fields X1 and Y1 for each record in query
' in appropriate row and column
' Column 1 is X values and column 2 is Y values
oDatasheet.Cells(RowCnt, 1) = .Fields("X1").Value
oDatasheet.Cells(RowCnt, 2) = .Fields("Y1").Value
.MoveNext
RowCnt = RowCnt + 1
Loop
.Close
End With

End Sub

This works just fine for a small number of data points to display. It is actually fairly fast. The nice thing about it is the number of data points is not set in stone...it is dynamic. Any number of X-Y plot sets can be used which would be dependant on the query.
SO I THEN got bold, and when I set it up to display 60 points of data, there is a delay (significant). Does anyone have an idea on how to change this so it speeds things up?
From what I can gather in reading other posts in some forums, when you use explicit references to the datasheet in a msgraph things slow down. However I may be wrong....sure hope so!
 

keiths

Registered User.
Local time
Today, 14:31
Joined
Feb 10, 2005
Messages
28
Graph Problem Resolved!!!

Further to my posts above, I found an elegant method to resolve my graphing problem, which works quite well. It was simple, and was so easy it is scary!
A colleague of mine steered me in the right direction when I explained my problem over coffee.....

I just created a "dummy" record for the first record in the query I use for getting my graphing points. There are all sorts of ways to do it...easiest is by creating a join in the sql of the query, and having the "join" create a dummy query record which is the first record of the query.
Of course, this depends on what you are basing your query on. As I am querying the data in a table that is refreshed all the time, it was a no-brainer to create the record.
Sometimes the easiest solution is just looking right at you!
 

keiths

Registered User.
Local time
Today, 14:31
Joined
Feb 10, 2005
Messages
28
Should this be in the FAQ section????

In reviewing past posts over a while, this question has come up. Just a suggestion, but maybe if it was in the FAQ area it would be beneficial...
 

Users who are viewing this thread

Top Bottom