Report Syntax setting rowsource

C

cbjames

I have a report that contains a chart(graph). I want set the "rowsource" at
runtime. I used the following syntax, but it does not like the reference
syntax. I'm stuck.
-----
"[Reports]![chart1]![chartYTD].RowSource = "SELECT
[WeekNum],Sum([Apps_Sent]) AS [Apps Sent] FROM [qchart_Wk_apps] GROUP BY
[WeekNum];"

DoCmd.OpenReport "chart1", acPreview
 
D

Duane Hookom

The report would need to be open in order to set a property of any control
on the report. I would use a saved query as the Row Source of the chart.
Assuming you have a saved query named "qtotMyChart", you could use code
before you open the report like:

Dim strSQL as String
strSQL = "SELECT [WeekNum], Sum([Apps_Sent]) AS [Apps Sent] " & _
" FROM [qchart_Wk_apps] GROUP BY [WeekNum];"
CurrentDb.Querydefs("qtotMyChart").SQL = strSQL
DoCmd.OpenReport "chart1", acPreview
 

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