Problem programatically changing Chart RowSource

S

SFatz

I am using Access 2003 and have created a template report in which I
have inserted a chart. In design mode, I add a SQL string to to the
RowSource property in order to define the data for the chart. When I
launch the report, all works well.
Now I want to change the RowSource value programatically in the
report's Open method. If I do this I get the following error:

Run-time error '2455' You entered an expression that has an invalid
reference to the property RowSource.

If I Debug from the error, and step through the program, it eventually
prints the report as expected (no apparent errors). I've searched the
net for references to this problem, but have found nothing specific to
charts.

I've included the code below for reference. The name of the chart
object is chtData. Eventually I will add prompts to the user for the
strS and strE values along with the appropriate error checking.
'----CODE STARTS HERE----
Private Sub Report_Open(Cancel As Integer)
Dim strS As String
Dim strE As String
Dim strQ As String
strS = "01/01/04"
strE = "02/01/04"
strQ = "SELECT DISTINCTROW HourLog.ProjectID,
Sum(HourLog.TimeBilled) " _
& "AS [Sum Of TimeBilled] " _
& "FROM HourLog " _
& "WHERE (((HourLog.DateBilled) > #" & strS & "# " _
& "And (HourLog.DateBilled) <= #" & strE & "#)) " _
& "GROUP BY HourLog.ProjectID " _
& "ORDER BY HourLog.ProjectID;"
Me.chtData.RowSource = strQ
Me.lblSubTitle.Caption = "(" & strS & "-" & strE & ")"
End Sub
'----END OF CODE----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top