Solved

Multiple form printing

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

863 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

26 Experts available now in Live!

Get 1:1 Help Now