Kamis, 23 Juni 2016

Re: [MS_AccessPros] Print Dialogue Box not printing columns correctly

 

Doyce-


For this sort of problem, I use a Tally table to generate blank rows in the Record Source rather than rely on code.  Your Tally table needs an integer column with rows containing values from 1 to the max number of labels on a page.  Then your Record Source looks like:

SELECT " " As PersonName, " " As PersonAddress, " " As PersonCity, …
FROM TallyTable
WHERE TallyTable.Counter <= [Forms]![SomeForm]![RowsToSkip]
UNION ALL
SELEC PersonName, PersonAddress, PersonCity, …
FROM MyTable

Open your dialog (it must open WindowMode:=acdialog) from the report Open event - Open occurs BEFORE the record source gets loaded.  The user picks the number of rows to skip (can be zero), then clicks a button that runs code to hide the form to let the Open event continue.  In the Close event of the report, close the hidden form.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jun 23, 2016, at 2:10 PM, winberry.doyce@con-way.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.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: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Poskan Komentar