Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Multiple form printing

Posted on 1998-02-06
2
219 Views
Last Modified: 2008-02-01
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
Comment
Question by:bneuman
2 Comments
 
LVL 3

Accepted Solution

by:
guillems earned 100 total points
ID: 1967780
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
 

Author Comment

by:bneuman
ID: 1967781
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question