Modificar la margen de página del informe por código

Cordial saludo.
Necesito modificar la margen superior de página del informe a partir de un valor en una caja de texto
Gracias por tu ayuda

1 Respuesta

Respuesta
1
Incorpora el siguiente código en el modulo del formulario donde tienes el botón de abrir el informe y la caja de texto del margen.
'-----------------------------------------------------
Private Type str_PRTMIP
    strRGB As String * 28
End Type
Private Type type_PRTMIP
    xLeftMargin As Long
    yTopMargin As Long
    xRightMargin As Long
    yBotMargin As Long
    fDataOnly As Long
    xWidth As Long
    yHeight As Long
    fDefaultSize As Long
    cxColumns As Long
    yColumnSpacing As Long
    xRowSpacing As Long
    rItemLayout As Long
    fFastPrint As Long
    fDatasheet As Long
End Type
Private Sub Comando2_Click()
    Dim PrtMipString As str_PRTMIP
    Dim PM As type_PRTMIP
    Dim rpt As Report
    ' Open the report.
    DoCmd.OpenReport "informe1", acDesign
    Set rpt = Reports("informe1")
    PrtMipString.strRGB = rpt.PrtMip
    LSet PM = PrtMipString
    ' Set margins.
    PM.xLeftMargin = 1 * 1440
    PM.yTopMargin = Me.Texto0 * 1440
    PM.xRightMargin = 1 * 1440
    PM.yBotMargin = 1 * 1440
    ' Update property.
    LSet PrtMipString = PM
    rpt.PrtMip = PrtMipString.strRGB
    Set rpt = Nothing
    DoCmd.OpenReport "informe1", acViewPreview
End Sub
'-----------------------------------------------------------
Comando2 es el nombre del botón que abre el informe
Informe1 es el nombre del informe
Texto0 es el Textbox donde ponemos las pulgadas de margen superior.
Juega con el código y me comentas si tienes algún problema.
Una aperta.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas