J
Jasonm
I have an additional question related to my previous post (pasted below)
that now involves order of operations and why vb does not seem to operate
with breakpoints when a report is opened acViewNormal from a command
button?!
I have break points inserted to track where my code is not operating and I
am sending line counts to the immediate window to determine at which point
my code quits firing.
What I have found is that all of my code is running however, when the second
report opens all code ceases to function!
Here is my current code:
Private Sub Report_Open(Cancel As Integer)
Dim strMessage, strTitle, strTemp, strWoName As String
Dim intPrintRelated As Integer
strTemp = ""
Debug.Print "one"
strTemp = Nz(DLookup("WorkOrderNumber", "workordersall",
"(WorkordersAll.Name ) LIKE '1720-d*'"), "null")
strWoName = Nz(DLookup("Name", "workordersall", "(WorkordersAll.Name ) LIKE
'1720-d*'"), "null")
If strTemp = "null" Then
Exit Sub
Debug.Print "two"
Else
strMessage = "There are related Documents for Work Order # " &
vbCrLf
strMessage = strMessage & strTemp & " - " & strWoName & vbCrLf
strMessage = strMessage & "Do you want to print the related
documents?"
strTitle = "Approve Printing Related Documents?"
intPrintRelated = MsgBox(strMessage, vbYesNo, strTitle)
Debug.Print "three"
If intPrintRelated = 6 Then
If Me.OpenArgs = "Preview" Then
DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
strPrintMe = ""
Else
Debug.Print "four"
strPrintMe = "Print Me"
End If
Debug.Print "five"
End If
Debug.Print "six"
End If
Debug.Print "seven"
End Sub
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Debug.Print "eight"
End Sub
Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
Debug.Print "nine"
If strPrintMe = "print me" Then
Debug.Print "ten"
DoCmd.OpenReport "rptBlankTurbCalWorksheet", acViewNormal
Debug.Print "eleven"
End If
Debug.Print "twelve"
End Sub
All the code ifres sequentially up until eleven, (ten is the last to print
in the immediate window). there is a breakpoint installed at Report_Open,
but as I said it does not stop the code when opened in acViewNormal.
Any assistance would be appreciated. (my previous related post is below...)
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
that now involves order of operations and why vb does not seem to operate
with breakpoints when a report is opened acViewNormal from a command
button?!
I have break points inserted to track where my code is not operating and I
am sending line counts to the immediate window to determine at which point
my code quits firing.
What I have found is that all of my code is running however, when the second
report opens all code ceases to function!
Here is my current code:
Private Sub Report_Open(Cancel As Integer)
Dim strMessage, strTitle, strTemp, strWoName As String
Dim intPrintRelated As Integer
strTemp = ""
Debug.Print "one"
strTemp = Nz(DLookup("WorkOrderNumber", "workordersall",
"(WorkordersAll.Name ) LIKE '1720-d*'"), "null")
strWoName = Nz(DLookup("Name", "workordersall", "(WorkordersAll.Name ) LIKE
'1720-d*'"), "null")
If strTemp = "null" Then
Exit Sub
Debug.Print "two"
Else
strMessage = "There are related Documents for Work Order # " &
vbCrLf
strMessage = strMessage & strTemp & " - " & strWoName & vbCrLf
strMessage = strMessage & "Do you want to print the related
documents?"
strTitle = "Approve Printing Related Documents?"
intPrintRelated = MsgBox(strMessage, vbYesNo, strTitle)
Debug.Print "three"
If intPrintRelated = 6 Then
If Me.OpenArgs = "Preview" Then
DoCmd.OpenReport "rptBlankTurbCalWorksheet",
acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
strPrintMe = ""
Else
Debug.Print "four"
strPrintMe = "Print Me"
End If
Debug.Print "five"
End If
Debug.Print "six"
End If
Debug.Print "seven"
End Sub
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Debug.Print "eight"
End Sub
Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
Debug.Print "nine"
If strPrintMe = "print me" Then
Debug.Print "ten"
DoCmd.OpenReport "rptBlankTurbCalWorksheet", acViewNormal
Debug.Print "eleven"
End If
Debug.Print "twelve"
End Sub
All the code ifres sequentially up until eleven, (ten is the last to print
in the immediate window). there is a breakpoint installed at Report_Open,
but as I said it does not stop the code when opened in acViewNormal.
Any assistance would be appreciated. (my previous related post is below...)
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