Print prompt in a form not working

G

Guest

I got some help earlier for generating a print preview &/or print prompt in a
form. I was well-advised, except the following language doesn't work. It
doesn't bring the user back to the form to once again enter the Project
Number if he selects "No" to printing the report.

' show form
Me.Visible = True
' clear text box ready for next search
Me.txtProjectNumber = ""
' move focus to report in preview if open
On Error Resume Next
DoCmd.SelectObject acReport, conREPORTNAME

Can you see anything wrong with it?
 
P

Pieter Wijnen

I don't know the history but

' show form
Me.Visible = True
' clear text box ready for next search
Me.txtProjectNumber = ""
' move focus to report in preview if open
On Error Resume Next
DoCmd.SelectObject acReport, conREPORTNAME
if err.number <>0 then
docmd.openforn me.name
end if

might do it for you

Pieter
 
G

Guest

Thanks. The only gliche is that the report that I initially previewed, stays
open behind the second prompt for another Project Number. Here's the 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top