K
Karen
I've got the following OnClick event in a form to print preview and or print
a report. The only gliche is that the report that is initially previewed
stays
open behind the second prompt for another Project Number. Here's the On click
Event Procedure currently:
Private Sub View_Results_of_Single_Pending_Project_Click()
Const conREPORTNAME = "PROJ HISTORY -ALL PENDING - RPT"
Const conMESSAGE = "Do you wish to print the report?"
Dim strCriteria As String
strCriteria = "[Project Number]=""" & Me.txtProjNo & """"
'hide form
Me.Visible = False
'open report in print preview
DoCmd.OpenReport conREPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria
'if user confirms, print report
If MsgBox(conMESSAGE, vbQuestion + vbYesNo, "Print Report") = vbYes Then
'close print preview
DoCmd.Close acReport, conREPORTNAME
'print report
DoCmd.OpenReport conREPORTNAME, _
View:=acViewNormal, _
WhereCondition:=strCriteria
End If
'show form
Me.Visible = True
'clear text box ready for next search
Me.txtProjNo = ""
'move focus to report in preview if open
On Error Resume Next
DoCmd.SelectObject acReport, conREPORTNAME
If Err.Number <> 0 Then
DoCmd.OpenForm Me.Name
End If
End Sub
What do I change so that if the user selects "No" to "Do you wish to
print?," the current report being previewed is closed before he is prompted
to enter another Project Number?
a report. The only gliche is that the report that is initially previewed
stays
open behind the second prompt for another Project Number. Here's the On click
Event Procedure currently:
Private Sub View_Results_of_Single_Pending_Project_Click()
Const conREPORTNAME = "PROJ HISTORY -ALL PENDING - RPT"
Const conMESSAGE = "Do you wish to print the report?"
Dim strCriteria As String
strCriteria = "[Project Number]=""" & Me.txtProjNo & """"
'hide form
Me.Visible = False
'open report in print preview
DoCmd.OpenReport conREPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria
'if user confirms, print report
If MsgBox(conMESSAGE, vbQuestion + vbYesNo, "Print Report") = vbYes Then
'close print preview
DoCmd.Close acReport, conREPORTNAME
'print report
DoCmd.OpenReport conREPORTNAME, _
View:=acViewNormal, _
WhereCondition:=strCriteria
End If
'show form
Me.Visible = True
'clear text box ready for next search
Me.txtProjNo = ""
'move focus to report in preview if open
On Error Resume Next
DoCmd.SelectObject acReport, conREPORTNAME
If Err.Number <> 0 Then
DoCmd.OpenForm Me.Name
End If
End Sub
What do I change so that if the user selects "No" to "Do you wish to
print?," the current report being previewed is closed before he is prompted
to enter another Project Number?