• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Multiple form printing

I have the following code thats works well. I can print out forms within a certain date range. Under one button I print out five different forms at once (only if they contain data). My problem is that if the first form of the five does not contain data the other 4 reports won't print. Even if they contain data. Can someone tell me how to correct this? Heres the code: (under case 4)
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
    ' This procedure used in Preview_Click and Print_Click Sub procedures.
    ' Preview or print report selected in the ReportToPrint option group.
    ' Then close the Print Sales Reports Dialog form.

    Dim strWhereCategory As String
    If Me![optBeginDt] = "" Or Me![optEndDt] = "" Then
        Beep
        MsgBox "Please enter a valid start date", vbInformation, "Date Error"
        Me![optBeginDt].SetFocus
    Else

    strWhereCategory = "date between Forms![Daily Reports]!optBeginDt and Forms![Daily Reports]!optEndDt"

        Select Case Me![ReportToPrint]
            Case 1
                DoCmd.OpenReport "Oxygen Report1", PrintMode, , strWhereCategory
            Case 2
                DoCmd.OpenReport "Roast Colors Report", PrintMode, , strWhereCategory
            Case 3
                DoCmd.OpenReport "Bulk Report", PrintMode, , "[Date Rec'd] between Forms![Daily Reports]!optBeginDt and Forms![Daily Reports]!optEndDt"
            Case 4
                DoCmd.OpenReport "GrindA1 Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "GrindA1U Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "GrindA2 Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "GrindA3 Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "GrindA4 Report", PrintMode, , strWhereCategory
            Case 5
                DoCmd.OpenReport "Difference Report", PrintMode, , strWhereCategory
            Case 6
                DoCmd.OpenReport "Roasted Bulk/Moisture Report", PrintMode, , strWhereCategory
            Case 7
                DoCmd.OpenReport "Oxygen Report1", PrintMode, , strWhereCategory
                DoCmd.OpenReport "Roast Colors Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "Bulk Report", PrintMode, , "[Date Rec'd] between Forms![Daily Reports]!optBeginDt and Forms![Daily Reports]!optEndDt"
                DoCmd.OpenReport "Grind Analysis Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "Difference Report", PrintMode, , strWhereCategory
                DoCmd.OpenReport "Roasted Bulk/Moisture Report", PrintMode, , strWhereCategory
        End Select
    DoCmd.Close acForm, "Daily Reports"
    End If
0
bneuman
Asked:
bneuman
1 Solution
 
guillemsCommented:
I try to do this before to print a report.

If the records attach to a query or recordset, before to print a record I'll try to check the query and if no contains information, not print the report.

  (...)
function PrintReport (Name as string) as variant
  dim midb as database
  set midb = dbengine.workspaces(0).databases(0)
  dim c as recordset
  set c = midb.openrecordset(name)
  if not c.eof then '-- the query has records
      PrintReport = True
  else
      PrintReport = False
  end if
end function

(...)
  in the code befor to print call the function.
      if (PrintReport ("<query's report>") then
             docmd openreport ...
     end if
(...)

I suppose that it works.  Tell me if this do not work.
0
 
bneumanAuthor Commented:
Would like to open this up to other experts. Can't seem to make this theory work for my situation. Need more info.....

Bill
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now