Doyce
---In MS_Access_Professionals@yahoogroups.com, <winberry.doyce@con-way.com> wrote :
Hello Pros!
I have a report that has 2 columns that prints labels on letter size paper. I have some code in the report that lets you choose which row and column to start printing on from controls on the form to save paper if you don't use all the labels from a previous print. Here's the problem. I decided that I wanted a printer dialogue to open in case the printer needed is not the default printer so I changed the code behind the "print" button from:
DoCmd.OpenReport stDocName, acNormal
to:
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.RunCommand acCmdPrint
which opens the print dialogue box but it always starts printing on row 1 column 1 instead of whatever I specified on the form. It then shows a preview of the report which appears correctly on the screen. Here is the code on the report that works correctly if I use DoCmd.OpenReport stDocName, acNormal which prints to the default printer:
Option Compare Database
Option Explicit
Private Const TotCols As Long = 2
Private StartRecord As Long, RecordCount As Long
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me.Detail.WillContinue = False Then
RecordCount = RecordCount + 1
End If
If RecordCount < StartRecord Then
Me.NextRecord = False
Me.PrintSection = False
Else
Me.NextRecord = True
Me.PrintSection = True
End If
End Sub
Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As Integer)
RecordCount = 0
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim StartRow As Long, StartCol As Long
Dim FormName As String
FormName = "frmPartMasterLabels3x4"
StartRow = Forms(FormName)("TxtStartRow")
StartCol = Forms(FormName)("TxtStartColumn")
'For across then down use: StartRecord = StartCol + (StartRow - 1) * TotCols
'For down then across use: StartRecord = (StartCol - 1) * 3 + StartRow
StartRecord = StartCol + (StartRow - 1) * TotCols
RecordCount = 0
End Sub
This code is from AD Tejpal. Any ideas how to tweak this to let me open the printer dialogue box and still get the correct output?
Doyce
Posted by: wrmosca@comcast.net
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar