changing graph row source with VBA.

Fuga

Registered User.
Local time
Today, 22:26
Joined
Feb 28, 2002
Messages
566
My idea is to use a scrollbar to adjust period of the records displayed in a graph, so by dragging the scrollbar the user sets the "end date" of the graph´s sql. However, I´m running into problems:


Private Sub Form_open(cancel As Integer)

Dim intsliderslut As Integer
Dim rsslider As DAO.Recordset
Dim sliderdate As String, sliderdate2 As String
Dim dtsliderdate As Date, dtsliderdate2 As Date
Dim intval As Integer


Set rsslider = CurrentDb.OpenRecordset("select datum from urvalstabell order by datum asc")
intsliderslut = DCount("datum", "urvalstabell")
Me.ActiveXkontroll8.Min = 1
Me.ActiveXkontroll8.Max = intsliderslut
Me.ActiveXkontroll8.Value = intsliderslut
intval = Me.ActiveXkontroll8.Value
rsslider.MoveFirst
rsslider.Move strval
dtsliderdate = rsslider.Fields("datum")
dtsliderdate2 = dtsliderdate - 100
sliderdate = dtsliderdate
sliderdate2 = dtsliderdate2
Me.Field12.RowSource = "SELECT DISTINCTROW Format([Datum],"dddd") AS Uttryck1, Sum([kursurval med xtrem].Senast) AS SummaförSenast, Sum([kursurval med xtrem].Högst) AS SummaförHögst, Sum([kursurval med xtrem].Lägst) AS SummaförLägst, Sum([kursurval med xtrem].topvärde) AS Summaförtopvärde, Sum([kursurval med xtrem].bottenvärde) AS Summaförbottenvärde, Sum([kursurval med xtrem].Först) AS SummaförFörst FROM [kursurval med xtrem] GROUP BY Format([Datum], "dddd"), [kursurval med xtrem].Datum HAVING ((([kursurval med xtrem].Datum) Between " & sliderdate & " And " & sliderdate2 & "));"
Me.Refresh

End Sub


when I open the form, the graph don´t show at all. I think the problem is when setting the row source, because during the programming I have recieved errormessages indicating that all is well until the very end. Could it have something to do with the "dddd" formatting?

BTW - I can´t seem to get the "code - mode" when I post messages in the forum.

Fuga.
 
Last edited:
Solved it!

Ok everyone.

I solved my problem by making a parameter query as the graph´s row source, and then building two functions for the parameters. ( I´m actually quite proud of myself).

However, this caused a new problem:

when I set the period and number of records to maximum, the graph does not show all records. Is there a limit to how many records a graph can show?? At most there are maybe 500 records.

Fuga.
 

Users who are viewing this thread

Back
Top Bottom