I open a form and depending on the command button that I click, the values for the report and query name are placed in 2 text fields.
I select a value from the combo box, and modify my where clause depending on the value selected, then I click on the command button to open the report.
Problem: on the first try the query is not change and/or the report does not load with the modified query!!! But when I close the report, and click the command button again, it works!?!
When I put breakpoints, everything works fine...
Any suggestions?
Thanks,
PNC.
I select a value from the combo box, and modify my where clause depending on the value selected, then I click on the command button to open the report.
Problem: on the first try the query is not change and/or the report does not load with the modified query!!! But when I close the report, and click the command button again, it works!?!
When I put breakpoints, everything works fine...
Code:
Dim stDocName As String
Dim qryDef As QueryDef
Dim Q As String
Dim Rel As String
Dim QryName As String
stDocName = Me!RptName.Value
QryName = Me!QryName.Value
Me.Combo_Release.SetFocus
'Specify the release name
If IsNull(Me.Combo_Release) = True Then
Rel = "dbo.Incident.ReleaseName or dbo.Incident.ReleaseName is null)"
Else
Rel = "'" & Me.Combo_Release.Text & "')"
End If
Set qryDef = CurrentDb.QueryDefs(QryName)
Q = qryDef.SQL
'Modify query
qryDef.SQL = Q & " And (dbo.Incident.ReleaseName =" & Rel
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
' Reset query to default
qryDef.SQL = Q
Any suggestions?
Thanks,
PNC.