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.RunCommand 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.Printer 'Default Printer
Set Application.Printer = Application.Printers(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.OpenReport i, acViewNormal, , stLinkCriteria 'acNormal Use normal for direct print to printer, acPreview, to preview only
Next i
Exit_cmdPrintRep_Click:
Exit Sub
Err_cmdPrintRep_Click:
MsgBox ("Report Does not Exist") 'Err.Description
Resume Exit_cmdPrintRep_Click
End Sub
thanks
Oldroboman
4 1807
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......
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!
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. -
-
stLinkCriteria = "[InspectionID] =" & Forms![Booking Form]![InspectionID]
-
-
For Each i In stDocName
-
DoCmd.OpenReport i, acViewNormal, , stLinkCriteria 'acNormal Use normal for direct print to printer, acPreview, to preview only
-
Next i
-
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |