I have chart inside a report in Microsoft Access 2010 that gets its RecordSource via VBA in the OnLoad of the report. The reason is that I have a form where the user can select what to include in the report. So the query that is set in VBA is
Me.Chart01.RowSource = "xxxx WHERE tbl_cars.ID In (" & IDs & ");"
Me.Chart01.Requery
DoCmd.Requery
The problem is that the graph does not update. After doing MsgBox Me.Chart01.RowSource both before and after where I set the RowSource, the SQL seems to be correct. It works perferctly when I remove the In() part and try it in the Query Design.
(I load the RecordSource of the report the same way, and it works.)
Are the charts in Access too poor to be able to do this, or is there a solution to this problem?
Reports don’t refresh like forms, so if the chart is unbound you’ll have to take care and place the code changing the row source in an event which occurs before the report is rendered like the Format or Print event. I’m assuming the IDs you’re including in the SQL string are numeric and not strings.