• SetReportSize (Access 2k)

    • This topic has 11 replies, 4 voices, and was last updated 23 years ago.
    Author
    Topic
    #372270

    Good morning all: Does anyone have any information regarding SetReportSize and parameters/arguments it requires? TIA.

    Viewing 0 reply threads
    Author
    Replies
    • #594710

      It isn’t built into Access far as I know. Where did you run across it?

      • #594757

        Charlotte: I inherited a system with SetReportSize as a function/procedure in an OnClick event of a button. Code is as follows:

        Private Sub cmd_all_Click
        Dim rptName as String
        Dim rptSize as Integer
        Dim rptOrientation as Integer

        rptName = “Parking Permit Report”
        rptSize = 17 ‘1-letter, 5-legal, 17-11×17
        rptOrientation = 2 ‘1-portrait,2-landscape

        SetReportSize rptName, rptSize, rptOrientation
        End Sub

        Was wondering if there were any more arguments/parameters, such as setting margins, etc.

        Thanks for responding.

        • #594759

          I recon that the SetReportSize must have been a custom function that someone built.

          What happends when you position the curson inside the word SetReportSize and hold down SHIFT and press F2.

          Does it take you to the function?

          • #594763

            Jayden: Thanks much. I never even thought to check for a custom function.

            • #594764

              No Problem

              I gather that you found the function?

            • #594766

              Yes. Should have look a little harder. Thanks again.

            • #594773

              Hi Bill

              Could you post the SetReportSize custom function?

              Thanks. John

            • #594813

              John: Here it is. Plus the TYPE definitions, etc. that go along with it. Good luck.

              Option Compare Database
              Option Explicit

              Public CurrentStreet
              Public CurrentZip
              Public CurrentAddress

              Type str_DEVMODE
              RGB As String * 94
              End Type

              Type type_DEVMODE
              strDeviceName As String * 16
              intSpecVersion As Integer
              intDriverVersion As Integer
              intSize As Integer
              intDriverExtra As Integer
              lngFields As Long
              intOrientation As Integer
              intPaperSize As Integer
              intPaperLength As Integer
              intPaperWidth As Integer
              intScale As Integer
              intCopies As Integer
              intDefaultSource As Integer
              intPrintQuality As Integer
              intColor As Integer

              intDuplex As Integer
              intResolution As Integer
              intTTOption As Integer
              intCollate As Integer
              strFormName As String * 16
              lngPad As Long
              lngBits As Long
              lngPW As Long
              lngPH As Long
              lngDFI As Long
              lngDFr As Long
              End Type

              Function SetReportSize(rptName As String, rptPaper As Integer, rptOrientation As Integer)
              Dim DevString As str_DEVMODE
              Dim DM As type_DEVMODE
              Dim strDevModeExtra As String
              Dim rpt As Report
              Dim intResponse As Integer
              ‘ Opens report in Design view.
              DoCmd.OpenReport rptName, acViewDesign

              Set rpt = Reports(rptName)
              If Not IsNull(rpt.PrtDevMode) Then
              strDevModeExtra = rpt.PrtDevMode ‘ Gets current DEVMODE structure.
              DevString.RGB = strDevModeExtra
              LSet DM = DevString

              DM.intPaperSize = rptPaper ‘ 1-letter, 5-legal, 17- 11×17
              DM.intOrientation = rptOrientation ‘1 – portrait, 2 – landscape

              LSet DevString = DM
              Mid(strDevModeExtra, 1, 94) = DevString.RGB
              rpt.PrtDevMode = strDevModeExtra
              DoCmd.Save

              DoCmd.OpenReport rptName, acViewPreview
              End If
              End Function

            • #594826

              This is pretty standard PrtDevMode usage. If you rummage in the help files, you’ll find other examples of its use, and there are samples of other uses here in the Lounge if you search the Access forum on PrtDevMode.

        • #594769

          Just me being pedantic but how about making your code more readable by using constants

          Private Sub cmd_all_Click
             Dim rptName as String
             Dim rptSize as Integer
             Dim rptOrientation as Integer
             
             const conLetter as integer = 1   'Paper Size Letter
             const conLegal as integer = 5   'Paper Size Legal
             const con11x17 as integer = 17 'Paper Size 11 x 17
          
             const conPortraint as integer = 1     'Portraint Orientation
             const conLandscape as integer = 2  'Landscape Orientation
          
             rptName = "Parking Permit Report"
             rptSize = con11x17
             rptOrientation = conLandscape
          
             SetReportSize rptName, rptSize, rptOrientation
          End Sub
          

          You could even get real flash and make the constants global so you can use them from any procedure (not just this one)?

          Just my 2cents.

          • #594770

            Well okay, maybe it doesn’t look more readable here….but I’m sure it would in the VBA Window

    Viewing 0 reply threads
    Reply To: SetReportSize (Access 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: