docmdPrintOut Question

mattstrachan

Registered User.
Local time
Today, 12:57
Joined
Feb 22, 2013
Messages
31
Hey all,

I am trying to get a report to print straight out without opening the report in a preview. Here is what I have so far. I know I need to use doCmd.PrintOut but I can not figure out the correct syntax to get it to work. I highlighted the code in question in red.

Private Sub btnPrintLabel_Click()
Dim strPrintLabel As String

If Forms!Product!Qty_Type = "single" Then 'generate 1x1 small label

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strPrintLabel = "[ProductID] = " & Me.[ProductID] 'Print current
DoCmd.OpenReport "Label_Single", acViewPreview, , strPrintLabel
End If
End If

End Sub


What would the syntax look like to print out the first page of the report.
 
Well, to print the report instead of previewing, delete acViewPreview from your code.
 
Perfect! Thank you. Do you know how to just get the first page to print?
 
Never used it myself, as I use the wherecondition to limit the records, but I think you're back to DoCmd.PrintOut, which lets you specify pages. Post your failing syntax and we'll try to sort it out.
 
Well the reason I am trying to limit the page count is because I am printing small labels and I can not figure out how to limit the width of the report I am using. So I could approach this from two directions. Here is what I have now:

DoCmd.PrintOut "Label_Single", , strPrintLabel, , acHigh, 1, Yes

I have a where condition that limits the report to just that record. If it is possible to reduce the width of a report to 2.25" instead of the 2.7917" that seems to be the smallest I can make it I could approach it from that way as well.
 
Did you look in help at the syntax? Those aren't even valid arguments.

DoCmd.PrintOut [printrange][, pagefrom, pageto][, printquality][, copies][, collatecopies]

So try this after opening, as this works on the active object.

DoCmd.PrintOut , 1,1
 

Users who are viewing this thread

Back
Top Bottom