J
Jasonm
I know that my subject line is a bit vague, but let me try and explain...
I open a report from a form by either pushing the Preview or Print button.
That report opens and if there are certain records on that report a message
box tells the user that there is a related report that can be printed out
and do they want to do this...
My code works well if only previewing, but I cannot get it to work with the
Print Button. The code is as follows:
Private Sub Report_Open(Cancel As Integer)
Dim strMessage, strTitle, strTemp As String
Dim intPrintRelated As Integer
strTemp = ""
strTemp = Nz(DLookup("WorkOrderNumber", "workordersall",
"(WorkordersAll.Name ) LIKE '1720-d*'"), "null")
If strTemp = "null" Then
Exit Sub
Else
strMessage = "There are related Documents for Work Order # " &
vbCrLf
strMessage = strMessage & "Do you want to print the related
documents?"
strTitle = "Approve Printing Related Documents?"
intPrintRelated = MsgBox(strMessage, vbYesNo, strTitle)
If intPrintRelated = 6 Then
If Me.OpenArgs = "Preview" Then ' The preview sets the
reports open arguments to Preview
DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
strPrintMe = ""
Else
' I was trying to print other document here by using
' DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewNormal
' This canceled both documents
strPrintMe = "Print Me"
End If
End If
End If
Debug.Print Cancel
End Sub
I have tried moving the print event to the print event of the report footer,
but that cancels the original report also... If anyone can help I would be
gratefull. I have spent about 6 hours reading and trying different locations
to get the second report to print, but think I have hit a stone wall...
Thanks much in advance...
Jasonm
I open a report from a form by either pushing the Preview or Print button.
That report opens and if there are certain records on that report a message
box tells the user that there is a related report that can be printed out
and do they want to do this...
My code works well if only previewing, but I cannot get it to work with the
Print Button. The code is as follows:
Private Sub Report_Open(Cancel As Integer)
Dim strMessage, strTitle, strTemp As String
Dim intPrintRelated As Integer
strTemp = ""
strTemp = Nz(DLookup("WorkOrderNumber", "workordersall",
"(WorkordersAll.Name ) LIKE '1720-d*'"), "null")
If strTemp = "null" Then
Exit Sub
Else
strMessage = "There are related Documents for Work Order # " &
vbCrLf
strMessage = strMessage & "Do you want to print the related
documents?"
strTitle = "Approve Printing Related Documents?"
intPrintRelated = MsgBox(strMessage, vbYesNo, strTitle)
If intPrintRelated = 6 Then
If Me.OpenArgs = "Preview" Then ' The preview sets the
reports open arguments to Preview
DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
strPrintMe = ""
Else
' I was trying to print other document here by using
' DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewNormal
' This canceled both documents
strPrintMe = "Print Me"
End If
End If
End If
Debug.Print Cancel
End Sub
I have tried moving the print event to the print event of the report footer,
but that cancels the original report also... If anyone can help I would be
gratefull. I have spent about 6 hours reading and trying different locations
to get the second report to print, but think I have hit a stone wall...
Thanks much in advance...
Jasonm