DBL
Registered User.
- Local time
 - Today, 00:04
 
- Joined
 - Feb 20, 2002
 
- Messages
 - 659
 
I have a two stage event on a report.  If the user hasn't printed the report by the time they click close it prompts them using the following:
Private Sub Report_Close()
Dim stdResponse As Integer
Dim Cancel As Integer
If Flag = 2 Then
    
stdResponse = (MsgBox("You have not printed these letters, do you want to do that now?", vbYesNo, "Print Letters"))
        
If stdResponse = vbYes Then
Cancel = True
ReportPrint 'Function
Forms!frmHAServiceLettersPrintDialog.List21.Requery
                
End If
                          
End If
Flag = 0
If IsLoaded("frmHAServiceLettersPrintDialog") Then Forms!frmHAServiceLettersPrintDialog.Visible = True
End Sub
if they want to print the report the ReportPrint function kicks in:
Dim db As Database
Dim rs As DAO.Recordset
Dim result As String
Set db = CurrentDb
Dim msg As String
Dim stdResponse As Integer
Dim Cancel As Integer
If Flag = 2 Then
    
stdResponse = (MsgBox("You are about to print service letters for the selected properties." & vbCr & vbCr & _
"Do you want to update the property records to show the service letters have been printed?", vbYesNo, "Update Records"))
        
If stdResponse = vbYes Then
Cancel = True
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateSLSent"
DoCmd.SetWarnings True
Flag = 0
                
DoCmd.PrintOut
                
Else
Cancel = True
MsgBox "You cannot print these letters at this time."
Exit Function
End If
End If
    
I'm getting an error 2585 "this action can't be carried out while processing a form or report event"
It's highlighting the DoCmd.PrintOut when I step through the code. Any idea what's stopping the code from running - I'm assuming it's because the other code is on the Close event of the report - but how can I cancel the close event and let the ReportPrint function do it's thing?
Thanks
 Private Sub Report_Close()
Dim stdResponse As Integer
Dim Cancel As Integer
If Flag = 2 Then
stdResponse = (MsgBox("You have not printed these letters, do you want to do that now?", vbYesNo, "Print Letters"))
If stdResponse = vbYes Then
Cancel = True
ReportPrint 'Function
Forms!frmHAServiceLettersPrintDialog.List21.Requery
End If
End If
Flag = 0
If IsLoaded("frmHAServiceLettersPrintDialog") Then Forms!frmHAServiceLettersPrintDialog.Visible = True
End Sub
if they want to print the report the ReportPrint function kicks in:
Dim db As Database
Dim rs As DAO.Recordset
Dim result As String
Set db = CurrentDb
Dim msg As String
Dim stdResponse As Integer
Dim Cancel As Integer
If Flag = 2 Then
stdResponse = (MsgBox("You are about to print service letters for the selected properties." & vbCr & vbCr & _
"Do you want to update the property records to show the service letters have been printed?", vbYesNo, "Update Records"))
If stdResponse = vbYes Then
Cancel = True
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateSLSent"
DoCmd.SetWarnings True
Flag = 0
DoCmd.PrintOut
Else
Cancel = True
MsgBox "You cannot print these letters at this time."
Exit Function
End If
End If
I'm getting an error 2585 "this action can't be carried out while processing a form or report event"
It's highlighting the DoCmd.PrintOut when I step through the code. Any idea what's stopping the code from running - I'm assuming it's because the other code is on the Close event of the report - but how can I cancel the close event and let the ReportPrint function do it's thing?
Thanks