Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple form printing

Posted on 1998-02-06
2
Medium Priority
?
233 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
[X]
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
2 Comments
 
LVL 3

Accepted Solution

by:
guillems earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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