In Access 2010, I have a form, and a subform ("sfrm_HoursChart") which has a saved query ("myQuery") as its record source.
When a user manipulates the main form, I want to rebuild the SQL for the subform's underlying query, then refresh the subform. The subform is displayed as a pivot chart, if that's important.
The code I'm using is basically this:
Private Sub setChartPeriods()
Dim qdf as QueryDef
Dim qrySQL as String
'build new SQL string
qrySQL = *new SQL string*
Set qdf = CurrentDb.QueryDefs("myQuery")
qdf.SQL = qrySQL
Me.sfrm_HoursChart.Requery
End Sub
Trouble is, nothing happens, at least not immediately. If I close the form and reopen it (or if I open the subform as a standalone form), the subform's recordsource is updated properly using the new SQL, but it doesn't update upon
using the Requery method (which looks to me to be the right thing to do!)
I have also tried setting the focus to the subform and then running the Requery action (which I thought essentially closes and reopens the subform?) but that doesn't work either.