473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing a different value in a text box on multiple copies of same report

alpnz
113 New Member
Hi,
I am sure someone has managed this one before.
I have a report, which I call from a button on a form, which invokes the printing of 4 copies of a report. I would like to have a box on the report which prints "Office Copy" on the first page, "P.O.B." on the second pages etc.

The number of copies is set in the code on the Forms button. I have tried the following in the "On Print " Event on the report.
Expand|Select|Wrap|Line Numbers
  1.  
  2. PrintCount = 1
  3. Me.cpi_own = "Office Copy"
  4. PrintCount = 2
  5. Me.cpi_own = "P.O.B."
  6.  
  7. etc etc
  8.  
  9.  
Me.cpi_own being the text box on the report. Am I any where near the right method of achieving this type of event.

Any help appreciated.

John S
Dec 5 '06 #1
11 2831
alpnz
113 New Member
Off course it would be possible to have 4 text boxes nested on top of one another, and Use Me.Visible settings, however there must be a more eloquent way to achieve this.
Dec 5 '06 #2
NeoPa
32,569 Recognized Expert Moderator MVP
In the OnOpen event of the report you can do all sorts of things to affect how the report works.
Another problem here though is accessing the information that the caller knows (IE. the count number).
You can do this with a Public variable in a module (which should be visible to both caller and callee), or you can define a Function to handle setting and returning value(s).
Dec 5 '06 #3
alpnz
113 New Member
In the OnOpen event of the report you can do all sorts of things to affect how the report works.
Another problem here though is accessing the information that the caller knows (IE. the count number).
You can do this with a Public variable in a module (which should be visible to both caller and callee), or you can define a Function to handle setting and returning value(s).
This explains the post from "another" forum, suggesting you would need to set-up a table with the descriptors you want to use, and then refer to them in the OpenArgs. It then shows code, setting up just as you have suggested, a Public Variable in a module. This is where it all goes pear shaped for me, as I am not to sure by Module, does this mean setting up a module seperate to the Report, and the form that calls it. Or is it a module, for the specific control within the report. I will go get the suggested code.
JDS
Dec 5 '06 #4
alpnz
113 New Member
One suggested option is to setup a table with the Tag options.
E.g.
Table
TagID
Tag Description


Then

Expand|Select|Wrap|Line Numbers
  1. Sub sPrintMultipleReportCopies(strReportName As String, bytNumberCopies As Byte)
  2.  
  3. [color=green]'/ Example sPrintMultipuleReportCopies("MyReport",3)[/color]
  4.  
  5.  
  6.  
  7. Dim db As DAO.Database
  8.  
  9. Dim rec  As DAO.Recordset
  10.  
  11. Dim intCounter As Integer
  12.  
  13. Dim bytCounter As Byte
  14.  
  15.  
  16.  
  17. strSQL = "SELECT * FROM tblReprotNames”
  18.  
  19.  
  20.  
  21. Set db = CurrentDb()
  22.  
  23. Set rec = db.OpenRecordset(strSQL, dbOpenSnapshot)
  24.  
  25. rec.MoveFirst
  26.  
  27.  
  28.  
  29. For I = 1 to bytNumberCopies
  30.  
  31. DoCmd.OpenReport strReportName,,,rec.(“TagDescription”) [color=red]This line needs to be check for the OpenArgs argument[/color]
  32.  
  33. rec.MoveNext
  34.  
  35. Next I
  36.  
  37.  
  38.  
  39. rec.Close
  40.  
  41.  
  42.  
  43. End Sub
  44.  
  45.  
However I probably need this code explained to me Adrian.
:-)

By that I mean, is this the code in the control, or is it a Seperate Public Module.
Dumb Question??.

John S
Dec 5 '06 #5
NeoPa
32,569 Recognized Expert Moderator MVP
No Problem.
It is a separate module from both the form AND the report.
In the Project Explorer within the VBA window (Alt-F11 from Access then Ctrl-R) select Insert / Module.
The code you posted should be in a separate public module at a guess. It doesn't have Method type procedures (as you'd see in a Report or Form module).
Dec 5 '06 #6
alpnz
113 New Member
No Problem.
It is a separate module from both the form AND the report.
In the Project Explorer within the VBA window (Alt-F11 from Access then Ctrl-R) select Insert / Module.
The code you posted should be in a separate public module at a guess. It doesn't have Method type procedures (as you'd see in a Report or Form module).
I have given this idea a go, but it is all a bit obtuse to me.
When I enter the code as per the previous messages, I get a compile error at the DAO.etc etc part, saying Object not defined or some such.

This is how I see the code works.

It defines the "rec" recordset from the table "tbl_cpi", OK we can still get there, using a DLookup of the [cpi_desc] in the "tbl_cpi".

We can then rec.MoveFirst and for I = 1 OpenReport "The report" using rec as the OpenArgs
rec.MoveNext

Next I

etc etc.
However at compile time, it fails at the rec = part saying improper use of expression.

2 questions
Why would the DAO not work, and am I way of track trying to define the variables.
John S
Dec 6 '06 #7
NeoPa
32,569 Recognized Expert Moderator MVP
I can see why your
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport strReportName,,,rec.(“TagDescription”)
line would fail (wrong double-quote chars) but no idea why the
Expand|Select|Wrap|Line Numbers
  1. Set rec = db.OpenRecordset(strSQL, dbOpenSnapshot)
should have any problems.

BTW your
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM tblReprotNames”
line also has wrong char at end. Maybe this is causing subsequent line to fail.
Try fixing known problems and trying again.

Can't see any problems with your variable definitions.
Dec 6 '06 #8
MSeda
159 Recognized Expert New Member
you didn't say what code you used to invoke the printing in the on click event, but i tried using the following code to pass the label text via openargs

this is the code I used in the print button:

Private Sub Command4_Click( )

DoCmd.Close acForm, "Quote Printer"

DoCmd.OpenRepor t "Quote1", acNormal, , , , "Office Copy"
DoCmd.OpenRepor t "Quote1", acNormal, , , , "POB"
'etc...for each page

End Sub

I entered this code in the on format event for the report section where i had placed a textbox named "PageLabel"

Private Sub GroupHeader0_Fo rmat(Cancel As Integer, FormatCount As Integer)

Me.PageLabel = Me.OpenArgs

End Sub

I hope this can help.
Dec 6 '06 #9
alpnz
113 New Member
you didn't say what code you used to invoke the printing in the on click event, but i tried using the following code to pass the label text via openargs

this is the code I used in the print button:

Private Sub Command4_Click( )

DoCmd.Close acForm, "Quote Printer"

DoCmd.OpenRepor t "Quote1", acNormal, , , , "Office Copy"
DoCmd.OpenRepor t "Quote1", acNormal, , , , "POB"
'etc...for each page

End Sub

I entered this code in the on format event for the report section where i had placed a textbox named "PageLabel"

Private Sub GroupHeader0_Fo rmat(Cancel As Integer, FormatCount As Integer)

Me.PageLabel = Me.OpenArgs

End Sub

I hope this can help.
Many thanks for your reply. This is similar to how I started out trying to achieve this, and I may try again.
Dec 6 '06 #10

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

Similar topics

9
3075
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want to appear in the report is Yes, No, or Maybe. What do I need to do to change what appears in the report/what term do I need to search out in Google? Thank you Colin
16
48881
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use a commercial program such as Adobe Acrobat and its associated API. The technique uses Ghostscript and Redirection Port Monitor - two free programs for creating PDF documents provided free by Russell Lang. The actual automation requires VBA...
7
96315
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %% should be used. Wouldn't it have been better (from design perspective) if the same escape character had been used in this case too. Forgive me for posting without verfying things with any standard compiler, i don't have the means for now.
5
2498
by: Dave Richardson | last post by:
Hi, I'm having a nightmare trying to use a form as the basis of capturing the number of copies that a user requires of a report to be printed. I originally used the input box as a solution, but wanted something more elegent by using a txt control on a form instead. The input box code is like this: ' Accepts user input in order that the number of copies required for an exam may be input
4
16815
ADezii
by: ADezii | last post by:
Recently, there seems to be several questions specifically related to Printers and changing Printing characteristics for Forms and Reports. For this reason alone, I decided to dedicate this week's Tip to these Topics. The Tip will actually consist of several Tips which I feel are very useful for all Users, from Newbies to Experts. In order to utilize the code contained within these Tips, you must have Access 2002 or later. How can I...
3
6547
by: franc sutherland | last post by:
Hi, Is there a way to make a report print out more than once using the VBA code behind a button, without having to put the code in multiple times? I want to print out the same report four times, with page 1 of 4 through to 4 of 4 in the footer. Can anyone help?
18
11302
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing classes, for each of the checked rows in the GridView. This works fine in the Visual Studio 2005 development environment on localhost. But, when I move the page to the web server, I get the error "Settings to access printer...
0
2849
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the printing printing data and the actual database data in a recordset. the class looks like this: Public Class BRPDD 'Balance Report PrintingDocument Data Public totalReceiptsNum As Integer Public totalLicFee As Double
1
2260
by: ccmanc68 | last post by:
I would like to print two reports a once. The first report is a sign sheet; the second is an order form. The sign sheet contains the same information as the order form but has a different layout. The subform sometimes contains multiple records, currently if I have four records in the subform, and when I print these reports, it will print the first four signs followed by the four order form records. If I want ten copies each of the order...
0
8889
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
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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...
0
9257
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9116
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
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
6702
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
4519
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...
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.