Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copies of print from textbox in Access

Posted on 2012-03-23
3
Medium Priority
?
336 Views
Last Modified: 2012-06-27
I m want to print a random number of copies(reports) from an Access form using a textbox for example.

So basically i have a print button on form that would automatically print a report.I need to change the number of copies each time i print and i don t want to go through the process of changing it each time in the print properties.Can i set a textbox next to the print button that would take the appropriate number of copies and then print?
0
Comment
Question by:The_Nibbler
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1500 total points
ID: 37756415
Give this a try:


DoCmd.OpenReport "YourReportName", acViewPreview
DoCmd.PrintOut  Copies:=NZ(Me.YourTextBoxName,1)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37756439
Just a note - The NZ in the above code defaults the number of copies to 1 if the textbox is left blank/null.

You can set that default to anything you want, or include conditional code to not print anything at all if the textbox is blank.  

You should definitely customize the code in this respect to ensure it behaves like you want it to for special cases like blanks, zeros or typos/user input errors, and possibly set a 'sensible' upper limit for the allowable number of pages.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37756991
<No Points wanted>

For example, insert a combobox on the from in place or the textbox.
Load the combobox with integers from 1 to ...say 25.

Set the Limit to list property to: No
...so they cant really type in anything other than what is in the list.

Like mbizup states, you can set the default value to be 1 as well...


;-)

Jeffcoachman
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

926 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