473,804 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Report print filtering

18 New Member
Hi, I have a slighly annoying problem, I am using the below code to print out several reports that are linked by InspectionID field, my problem is that this works ... to a point, if I do preview it selects the correct records each time if i then print from preview it prints the single record, but when I use this code, it prints ALL the records, I look at the print queue and its saying pages up to the amount of records where there is data, where no data is on the record it just says 1 , how do i restrict the printout to the nominated record for all of them?

Sub PrintReport()
DoCmd.RunComman d acCmdSaveRecord
On Error GoTo Err_cmdPrintRep _Click
Dim stDocName As Variant
Dim i As Variant
Dim stLinkCriteria As String
Dim tmpPrinter As Printer
Dim filename As String
Set tmpPrinter = Application.Pri nter 'Default Printer
Set Application.Pri nter = Application.Pri nters(2) '("Canon PIXMA iP1000")


stDocName = Array("Page1", "Page2", "Page3", "Page4", "Page5", "Page6", "Page7", "Page8", _
"Page8a", "Page9", "Page9a", "Page10", "Page11", "Page12", "Page13", "Page14", _
"Page15", "Page15a", "Page16", "Page17", "Page18", "Page18a", "Page19", _
"Page19a", "Page20", "Page20a", "Page21", "Page21a", "Page22", "Page23", "Page24", _
"Page25", "Page26", "Page27", "Page27a", "Page27b", "Page28", "Page29", "Page30")

For Each i In stDocName
stLinkCriteria = "[InspectionID] =" & Forms![Booking Form]![InspectionID]
DoCmd.OpenRepor t i, acViewNormal, , stLinkCriteria 'acNormal Use normal for direct print to printer, acPreview, to preview only
Next i


Exit_cmdPrintRe p_Click:
Exit Sub

Err_cmdPrintRep _Click:
MsgBox ("Report Does not Exist") 'Err.Descriptio n
Resume Exit_cmdPrintRe p_Click

End Sub

thanks
Oldroboman
May 31 '07 #1
4 1823
oldroboman
18 New Member
Hi again, It would appear that I am looking in the wrong place here, on a lot closer inspection of the reports, i have stopped all the multi pages on most of them, (caused by size of the report page durrrr), but i still have one page that insists on producing 4 pages, but they are all of the same data, so how do I get round that one. the code sent before is obviously working fine. it just seems odd that one out of the 30 should be doing this, maybe Ill try a rebuild to see if that does it.. Ill let you know, but if there is a bright idea there, please let me have it thanks......
May 31 '07 #2
oldroboman
18 New Member
Hi again, It would appear that I am looking in the wrong place here, on a lot closer inspection of the reports, i have stopped all the multi pages on most of them, (caused by size of the report page durrrr), but i still have one page that insists on producing 4 pages, but they are all of the same data, so how do I get round that one. the code sent before is obviously working fine. it just seems odd that one out of the 30 should be doing this, maybe Ill try a rebuild to see if that does it.. Ill let you know, but if there is a bright idea there, please let me have it thanks......
Once more it has sorted itself in some respect, It turned out that the report that was causing the aggro was produced from a query, the rest were from tables, I split the report (it was two tables in a query) down to table level and its resloved the issue. they all come out as expected, thanks for the attention, I hope it solves someone elses problem!
May 31 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Just one thing, although I don't think it will change anything. I would remove setting stLinkCriteria outside the loop. There is no need to reset it each time.

Expand|Select|Wrap|Line Numbers
  1.  
  2. stLinkCriteria = "[InspectionID] =" & Forms![Booking Form]![InspectionID]
  3.  
  4. For Each i In stDocName
  5.     DoCmd.OpenReport i, acViewNormal, , stLinkCriteria 'acNormal Use normal for direct print to printer, acPreview, to preview only
  6. Next i
  7.  
  8.  
Jun 1 '07 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
Once more it has sorted itself in some respect, It turned out that the report that was causing the aggro was produced from a query, the rest were from tables, I split the report (it was two tables in a query) down to table level and its resloved the issue. they all come out as expected, thanks for the attention, I hope it solves someone elses problem!
The query was probably causing a problem because it already had criteria set and this can cause problems when you are trying to pass further criteria through the open report
Jun 1 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3787
by: Baz'noid | last post by:
Hi all, With the recent postal strikes here in the UK i'm trying to persuade access to email reports at the touch of a button. I've not been able to figure out how to filter the report - when i print a report via a button i have it filtering to just the customer and invoice on the form on screen, but when i email, it uses the customer details on screen for the email address but produces a separate HTML file for EVERY customer on the...
5
3093
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if I want to send the error report to Microsoft. Has anybody seen this type of error message and what can I do to prevent it from happening. Am I doing something illegal in my code? It used to work but I have added conditional formatting to a subform...
7
8875
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
2
2974
by: Will | last post by:
I have a 1 page report which I want to print numerous copies of. The number of copies will be specified by the user. My problem is that I want each report to print the copy number of number of copies, e.g. 1 of 6. I can set the report so the report prompts the user for the copy number and the number of copies but this means they have to enter 1 then 6 then print, 2 then 6 print etc. How can I set it so that when the report is opened it...
11
6607
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
2
14137
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002 database? Thanks, Dean Slindee
5
4621
by: sara | last post by:
I have reports that run from a form where the user can choose a date range, or they run automatically for a week in the "Weekly Reports" option. I created 2 queries and 2 reports - one query uses the WeekEndDate to filter, and its associated report heading says "For the week Ending " & forms!frmPrintReports.getWeekEndDate. The other query selects the date range using "Between" and the 2 dates on the form. Its associated report header...
6
1960
by: JonC | last post by:
I am developing an Access database and need to be able to print a form with various selections made as it appears on screen. The standard way of doing this would be to create a report based on the form but the form is quite complex with nested subforms and page tabs and trying to filter the records is proving to be a nightmare. I'm sure there must be some VB code that could do this for me but I'm a bit of a novice. Printing the screen...
2
2590
by: ccwells | last post by:
Hi, I am a novice to VB, using Access 2003 on a XP-SP2 platform, and I have a small database for tracking expenses, and want to be able to filter my expense report by date. I currently have a form with two list boxes, purchase and payment type, and then two date fields txtStartDate and txtEndDate. Filter works fine when no dates are chosen, problem is with my date picker - if I choose dates I get a "syntax error (missing operator)" error in...
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.