Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

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
0
JeffreyDurham
Asked:
JeffreyDurham
1 Solution
 
TerryInOhioCommented:
Print a page full text maybe from Word with the margins as small as you can get them on both a good and bad printer, compare the results.  If different it can't be your code.

I see your margins are all 0.  The HP printers I use can't handle anything smaller than .17 or .25, maybe that is confusing the printer.

Your code is probably fine, when strange things happen like yours to me, I suspect the print driver, perhaps reload it.

Maybe even move that printer to another computer for a test to see if it acts differently.

0
 
JeffreyDurhamAuthor Commented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now