J
jonefer
I tried updating a querydef in VBA, but I'm not having any success getting
the chart to update on the form:
If I manually change the query, close the form and then open it up again, it
changes. So it must be possible to do it programatically.
I've included my code.
The name of my chart object on the form is 'chCOLO'
The chart just needs 2 parameters to change the query:
Clinic, and PCP
I'm using the following two routines:
Private Sub cmdSearch_Click()
Call UpdateChartDefinitions(Me.cmbClinic.Value, Me.lblSelectedPCPs.Caption)
Me.chCOLO.Requery
End Sub
Private Sub UpdateChartDefinitions(strClinic As String, strPCP As String)
Dim strQry As String
Dim qdfCOLO As DAO.QueryDef
Dim rs As DAO.Recordset
Dim db As DAO.Database
strQry = "SELECT [PCP LOC], [PCP NAME], COLO, YYYYMM " _
& "FROM qAllMonths " _
& "WHERE [PCP LOC]= '" & strClinic & "' AND [PCP NAME] " & strPCP & " AND
COLO >0;"
Set db = CurrentDb
Set qdfCOLO = db.QueryDefs("qAllCOLO")
qdfCOLO.SQL = strQry
db.QueryDefs.Refresh
Set qdfCOLO = Nothing
Set db = Nothing
End Sub
the chart to update on the form:
If I manually change the query, close the form and then open it up again, it
changes. So it must be possible to do it programatically.
I've included my code.
The name of my chart object on the form is 'chCOLO'
The chart just needs 2 parameters to change the query:
Clinic, and PCP
I'm using the following two routines:
Private Sub cmdSearch_Click()
Call UpdateChartDefinitions(Me.cmbClinic.Value, Me.lblSelectedPCPs.Caption)
Me.chCOLO.Requery
End Sub
Private Sub UpdateChartDefinitions(strClinic As String, strPCP As String)
Dim strQry As String
Dim qdfCOLO As DAO.QueryDef
Dim rs As DAO.Recordset
Dim db As DAO.Database
strQry = "SELECT [PCP LOC], [PCP NAME], COLO, YYYYMM " _
& "FROM qAllMonths " _
& "WHERE [PCP LOC]= '" & strClinic & "' AND [PCP NAME] " & strPCP & " AND
COLO >0;"
Set db = CurrentDb
Set qdfCOLO = db.QueryDefs("qAllCOLO")
qdfCOLO.SQL = strQry
db.QueryDefs.Refresh
Set qdfCOLO = Nothing
Set db = Nothing
End Sub