Solved

Multiple form printing

Posted on 1998-02-06
2
213 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now