Link to home
Start Free TrialLog in
Avatar of Jeanette Durham
Jeanette DurhamFlag for United States of America

asked on

Printing DataReport is different on different printers, cutting off last line (Please Help)

Ok, I'm writing this program, and one of the things it does is use a datareport I've drawn up. It's got three labels across, and the idea is that it's an exact template for a particular 3x10 avery mailing labels. I've tested this on like 6 different printers at my work where I'm writing this, and we're trying to get the program ready to release. Anyways, one of the people who's testing it for us has a

    Brother MFC 9600 printer.

Anyways, here's what's going on, I can't figure out why his printer is doing this, since none of the others we've tested this on do this, but his printer is cutting off the last line. I'm wondering if anyone knows a way I could fix this so that he too could use our program?

Thanks! ~ Michael

'Here is all the related source code I use to display the datareport. I'm hoping that there is just something wrong with my code and all and it's not the printer, but if it isn't the code, is there a way to set the printer so it works anyways?

Dim myPrinter As Printer

Private Const OneInchInTwips = 1440     '1440 is equal to 1 inch
Private Const cLandscapeW = 1440 * 10
Private Const cLandscapeH = 1440 * 8
Private Const cPortraitW = 1440 * 8.5
Private Const cPortraitH = 1440 * 11

Private Sub btnLabels_Click()
    mnuPrintLabels_Click
End Sub

Private Sub mnuPrintLabels_Click()
    setPrinterMargins
On Error GoTo myerrhandler
    Set myDB.myLabelsSet = Nothing
    Set myDB.myLabelsSet = New ADODB.Recordset
    myDB.fillMailingTableFromRS
    DataReport1.LeftMargin = 0
    DataReport1.RightMargin = 0
    DataReport1.TopMargin = 0
    DataReport1.BottomMargin = 0
    setPortrait
    setSimplex
    '= vbPRDPSimplex  'print one side
    DataReport1.Orientation = rptOrientPortrait
    DataReport1.ReportWidth = cPortraitW
    DataReport1.Height = cPortraitH     'changed because page was cutting off
    Set DataReport1.DataSource = myDB.myLabelsSet
    DataReport1.Show
    Exit Sub
myerrhandler:
    MsgBox "Unable to display report. Try changing your `default printer' to a different printer."
    Err.Clear
    Exit Sub
End Sub


' --- Printer Config

Private Sub setPrinterMargins()
    Printer.ScaleLeft = 0
    Printer.ScaleTop = 0
    Printer.ScaleWidth = cPortraitW '11558
    Printer.ScaleHeight = cPortraitH    '15360
End Sub

Private Sub setPortrait()
    myPrinter.Orientation = vbPRORPortrait
    'Printer.Orientation = vbPRORPortrait
    'Set Printer = myPrinter
End Sub

Private Sub setLandscape()
    On Error GoTo setlandscapeerr
    Printer.Orientation = cdlLandscape
    'Set Printer = myPrinter
    Exit Sub
setlandscapeerr:
    Debug.Print Err.Description
    If InStr(Err.Description, "Invalid property value") > 0 Then
        Err.Clear
        'MsgBox "Your printer does not support Landscape Mode."
        Exit Sub
    End If
    Err.Raise Err.Number
End Sub

Private Sub setDuplex()
    'myPrinter.Duplex = 2
    On Error Resume Next
    Printer.Duplex = 2
    'Set Printer = myPrinter.
End Sub

Private Sub setSimplex()
    'myPrinter.Duplex = 1
    On Error Resume Next
    Printer.Duplex = AcPrintDuplex.acPRDPSimplex
    'Set Printer = myPrinter
End Sub
ASKER CERTIFIED SOLUTION
Avatar of TerryInOhio
TerryInOhio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeanette Durham

ASKER

Ok, I was able to fix it, and you were correct. The issue was that all the margins were set to 0 and his printer therefore supplied a default value which caused the last set of labels not to fit on the page. I changed them to a quarter inch on each side (left/right) and on the top and bottom set it to (half in. + quarter in.) /2 which yielded a working result.

Thanks for your advice!
~Michael