473,651 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I create a button that prints 2 copies of a form?

I'm trying to create a button that prints 2 copies of a form. Using
the wizard, I created a button that prints one automatically, using the
following code:

End Sub

Private Sub CSR_BeforeUpdat e(Cancel As Integer)

End Sub
Private Sub PRINTFORM_Click ()
On Error GoTo Err_PRINTFORM_C lick
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_PRINTFORM_ Click:
Exit Sub

Err_PRINTFORM_C lick:
MsgBox Err.Description
Resume Exit_PRINTFORM_ Click

End Sub

-------------------------------------END OF
CODE----------------------------------------------------

So anyone know how I can get it to print 2 copies automatically?
thanks for your help,

Adam

Feb 2 '06 #1
4 1880
Ted
First the simple answer:
Use a For...Next loop:
For x = 1 to 2
print commands
Next x

Second: The best answer for your client (and what I do):
Create a form (with a table behind it) that holds user preferences.
In that form have a box where the user can select the number of copies
to print (default to 2).
Let the user change that number if they want to print more or fewer
copies.
Modify your For...Next loop to:
For x = 1 to DLookup("[Copies]", "tblUserPre fs")
print commands
Next x

Ted
Adam - Regus wrote:
I'm trying to create a button that prints 2 copies of a form. Using
the wizard, I created a button that prints one automatically, using the
following code:

End Sub

Private Sub CSR_BeforeUpdat e(Cancel As Integer)

End Sub
Private Sub PRINTFORM_Click ()
On Error GoTo Err_PRINTFORM_C lick
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_PRINTFORM_ Click:
Exit Sub

Err_PRINTFORM_C lick:
MsgBox Err.Description
Resume Exit_PRINTFORM_ Click

End Sub

-------------------------------------END OF
CODE----------------------------------------------------

So anyone know how I can get it to print 2 copies automatically?
thanks for your help,

Adam


Feb 2 '06 #2
Ted,

I'm not sure where in the code I should put the code:

For x = 1 to 2
print commands
Next x

I would rather have the simple solution, as I'm not really a
programmer. I'm more the guy who delivers the mail, who happens to
know a little something about computers....bu t not enough!

Thanks Again,

Adam

Feb 2 '06 #3

Adam - Regus wrote:
I'm trying to create a button that prints 2 copies of a form. Using
the wizard, I created a button that prints one automatically, using the
following code:

End Sub

Private Sub CSR_BeforeUpdat e(Cancel As Integer)

End Sub
Private Sub PRINTFORM_Click ()
On Error GoTo Err_PRINTFORM_C lick
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_PRINTFORM_ Click:
Exit Sub

Err_PRINTFORM_C lick:
MsgBox Err.Description
Resume Exit_PRINTFORM_ Click

End Sub

-------------------------------------END OF
CODE----------------------------------------------------

So anyone know how I can get it to print 2 copies automatically?
thanks for your help,

Adam

I have not tried this solution but:
Private Sub CSR_BeforeUpdat e(Cancel As Integer)
End Sub
Private Sub PRINTFORM_Click ()
On Error GoTo Err_PRINTFORM_C lick
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
DoCmd.PrintOut acSelection

Exit_PRINTFORM_ Click:
Exit Sub
Err_PRINTFORM_C lick:
MsgBox Err.Description
Resume Exit_PRINTFORM_ Click
End Sub

Feb 4 '06 #4
I am on the road. I have no printer. If I had a printer I would try:

Private Sub PRINTFORM_Click ()
DoCmd.PrintOut
DoCmd.PrintOut
End Sub

But if I were designing the form there would be no button. I would tell
anyone who wanted two printed copies of the form to Click File > Print
and then to use the Spinner to select any number of copies needed.

What's worse than a Button that duplicates a method made available by
Access in a way that is consistent across almost all applications?
Can't guess? It's a Button that duplicates a method made available by
Access in a way that is consistent across almost all applications whose
Click Event has been scripted by a wizard.
"DoCmd.DoMenuIt em acFormBar, acEditMenu, 8, , acMenuVer70" means
absolutely nothing to me; perhaps it's possible that in some
situations it may mean absolutely nothing to Access/VBA.

Eighty per cent of all poor code and practices can be traced to
Wizards. And Northwind is directly responsible for another eighty per
cent. The rest is attributable to the Help file.

Feb 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
19756
by: Elliot Temple | last post by:
How do I make Python press a button on a webpage? I looked at urllib, but I only see how to open a URL with that. I searched google but no luck. For example, google has a button <input type=submit value="Google Search" name=btnG> how would i make a script to press that button? Just for fun, is there any way to do the equivalent of typing into a text field like the google search field before hitting the button? (I don't actually...
4
3403
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document write and it works fine until she puts it into a function and then calls the function from a button with onClick. This also seems to work OK, with the exception that the page is cleared, and the curser changes (and stays) as an hourglass. In...
7
8849
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
8
20354
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
0
3221
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want to register new customer or companies they will enter the information in Windows Form and the program automaticaly creates the WORD document under specific folder under application path. Once the empty word file created than ask user if they want...
23
7395
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
2
17712
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
1
11473
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date into txtDate on frmDate and the clicks "View Queried Privacy Records" Once they click this it opens the query form frmPrivacy which then has a command button cmdMailmerge to perform the mail merge and print the records that result from that query. (I...
1
2259
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
8277
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
8803
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
8581
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
7298
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
6158
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
5612
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
4144
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...
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.