Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.PrintOut Problems

Status
Not open for further replies.

JHHPavel

Technical User
Jul 18, 2003
29
US
My database prints several different types of labels. We start with a separate form for each type where the user enters the data to go on the label. Before printing, the user enters the number of copies needed in a text box on the form. Although the coding for the print button is the same on all forms, some work and some don't. I've compared line for line and they look the same. The code is below; we pick up the number of copies in this case from text box Text65.

Dim LabelNumber As Integer
LabelNumber = Forms![fSpecialLabel]![Text65]
DoCmd.OpenReport "rSpecialFormulaWithIngredients", acViewPreview
DoCmd.PrintOut , , , , LabelNumber

When debugging, Access highlights the last line shown above. It also gives the value of the LabelNumber, which is always the value we put into the text box.

I've tried just typing a number in the last line, instead of the LabelNumber variable but it doesn't accept that, either.
 
some work and some don't
Any error message ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
For about 20 years of programming in Access and creating thousands of reports, I don't recall ever using DoCmd.PrintOut. I typically add a table of numbers to the record source of my reports.

[pre]
tblNums
=======
Num
(numeric field with values 1 - some high enough number)

[/pre]

I then use code like:

Code:
Dim intLabelNumber As Integer
intLabelNumber = Me.txtNumberOfLabels
DoCmd.OpenReport "rSpecialFormulaWithIngredients", acViewPreview, , "[Num]<=" & intLabelNumber


Duane
Hook'D on Access
MS Access MVP
 
PHV: We get Run-time error "2501": The PrintOut action was canceled.

When we click the debug button, it takes us to the code and highlights the PrintOut line.


dhookom: That looks like an alternative but I'm curious as to why some of them work and some don't, even though all have the same DoCmd lines.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top