[AccessD] Change report marprint margins at runtime (Access XP )

Vinnie Chas vchas at comcast.net
Sat Jan 21 21:53:41 CST 2006


Hi Robert ,
Thanks so much for the direction. The following is what I ended up with.
Thanks so much for your help!

Public Function BuildAccessReport() As Boolean
    Dim stDocName As String
   
   'The printer is scaled in twips
   TwipsPerInch = 1440

   stDocName = "rpt1099"
   
   DoCmd.OpenReport stDocName, acViewPreview, , , acHidden

   Set XPReport = Access.Reports(stDocName)
   With Access.Reports(stDocName)
 
    .Printer.LeftMargin = DLookup("LeftMargin", "ReportList") * TwipsPerInch
    .Printer.RightMargin = DLookup("RightMargin", "ReportList") *
TwipsPerInch
    .Printer.TopMargin = DLookup("TopMargin", "ReportList") * TwipsPerInch
    .Printer.BottomMargin = DLookup("BottomMargin", "[ReportList]") *
TwipsPerInch

      
   End With
   DoCmd.OpenReport stDocName, PrintTo
   
   If PrintTo <> acViewPreview Then
    DoCmd.Close acReport, stDocName
   End If

End Function 

Vinnie Chas
www.vinniechas.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robert Gracie
Sent: Friday, January 20, 2006 9:34 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Change report marprint margins at runtime (Access XP
)

The best approach is to allow the users to set up the print formatting
requirements, and store those settings in a table... Something like this

Pulled from my Reports class, so hopefully you will get the idea.... Oh and
there is a BUNCH more you can do, this is just a very small example

Public Function BuildAccessReport() As Boolean
Dim RecordSuccBol           As Boolean
Dim ePrintTo                As acView

On Error GoTo HandleErr
If AccessReport = True Then
 If m_ePrintTo <> cOutputToPrinter Then
   ePrintTo = acViewPreview
 End If

   DoCmd.OpenReport m_sReportName, acViewPreview, "", SQL, acHidden
   Set A2KReport = Access.Reports(m_sReportName)
   With Access.Reports(m_sReportName)
    'If printing to the default printer, there is no need to set the
property
      If m_sPrinterName <> "{System Default}" Then
       Set A2KReport.Printer = Application.Printers(m_sPrinterName)
      End If
      
    .Printer.LeftMargin = m_dLeftMargin * TwipsPerInch
    .Printer.RightMargin = m_dRightMargin * TwipsPerInch
    .Printer.TopMargin = m_dTopMargin * TwipsPerInch
    .Printer.BottomMargin = m_dBottomMargin * TwipsPerInch
    
      If m_eOrientation = cLandscape Then
       .Printer.Orientation = acPRORLandscape
      Else
       .Printer.Orientation = acPRORPortrait
      End If
      
    .Printer.Copies = m_lCopies
    
   End With
   DoCmd.OpenReport m_sReportName, ePrintTo
   
   If ePrintTo <> acViewPreview Then
    DoCmd.Close acReport, m_sReportName
   End If

If m_bPrintSuc = True Then
  If PrintRecords(Now, 0, "Printed From: " & m_sCallingForm, m_lRN,
m_lCID) = False Then
    Call ErrorRecordSystem(0, "Print Error", Now, "Failed Record Print
Un-Expected Error In Proc; " & m_sCallingForm, CurrentUser)
  End If
End If
 
End If
ExitHere:
    Exit Function
HandleErr:
  Select Case Err.Number
   Case Else
      'MsgBox Err.BuildError("clsrptReport","BuildAccessReport"),
vbCritical, "Un-Expected Error"
       MsgBox "There has been an error in Procedure:
clsrptReport:BuildAccessReport " & vbCrLf & _
          "Error Number: " & Err.Number & vbCrLf & "Error Description: "
& Err.Description & vbCrLf & _
          "Please Contact " & "The SoftwareVendor" & " for more help
regarding this error. ", vbCritical, "Un-Expected Error"
       Call ErrorRecordSystem(Err.Number, Err.Description, Now, "Un-Expected
Error In Proc; " & "clsrptReport:BuildAccessReport ",
CurrentUser)
  End Select
End Function 


Robert Gracie
www.servicexp.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Vinnie Chas
Sent: Friday, January 20, 2006 10:45 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Change report marprint margins at runtime (Access XP
)

 Currently I have the report to print straight to the printer. I can change
it to preview to accomplish this. But is it possible to save the margin
settings to a table and then have the report use those so?



>>Oh yes the particular report needs to be in preview mode, then set and

>>it
will remain as 
>>long as the app is open.

>>Bill



>Hi Group,
>Access XP mde on windows XP machine
>Is there a way to change a reports print margin at runtime? I have a 
>custom print job to print W2's, W3's 1099's. On the development machine

>all text aligns correctly on preprinted forms. When I roll out the mde 
>to clients
I'm
>finding that depending on their printer, it doesn't line up correctly. 
>I then have to a just the reports margins for each individual customer.

>I
know
>I can do this in a mdb but a mde? Is this possible?

>TIA




--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 1/20/2006





More information about the AccessD mailing list