¿Cómo hago que Caption sea parte de mi formulario?
Estoy utilizando este código pero me marca un error el Caption que no es miembro de mi formulario y como lo hago miembro o como quito ese error me puedes decir por favor :)
' en este procedimiento exportamos el informe
' seleccionado en el ListBox
Dim ObjectType As Integer
Dim ReportName As String
Dim ExportFormat As String
Dim SNPFile As String
Dim OnlyOnce As Boolean
Dim Err As Object
If Me.AxListBox1.get_TopIndex > -1 Then
' tipo de objeto (acReport)
ObjectType = 3 'acOutputReport
' nombre del informe
ReportName = Me.AxListBox1.Text
' formato al que se exportará el informe
ExportFormat = "Snapshot Format (*.snp)"
' nombre y ruta del archivo que se exportará
SNPFile = oApp.Path & "\" & Me.AxListBox1.Text & ".snp"
On Error GoTo err_OutputTo
' exportamos el informe seleccionado al formato
' snapshot
oApp.DoCmd.OutputTo( _
ObjectType, ReportName, _
ExportFormat, SNPFile)
' cargamos el formulario donde se visualizarán los informes
Dim visua As New Form5()
visua.Show()
' le ponemos el nombre del informe que se mostrará
visua.Caption = "Informe: " & AxListBox1.Text
' vinculamos el archivo que hemos exportado con el visor
' de archivos Snapshot
visua.AxSnapshotViewer1.SnapshotPath = SNPFile
' eliminamos el archivo
Kill(SNPFile)
' mostramos el formulario
visua.Show()
' hacemos que el informe se ajuste al tamaño del formulario
visua.AxSnapshotViewer1.Zoom = SnapshotViewerControl.SnapZoom.snapZoomToFit
Else
MsgBox("Escoge un informe", vbExclamation, "Atención")
End If
Exit Sub
err_OutputTo:
If OnlyOnce = False Then
' si el formato snapshot no está disponible
If Err() = 2282 Then
' si se han podido cambiar las entradas erróneas del registro
If ChangeReg() Then
' reiniciaremos la aplicación Access para que los cambios
' surtan efecto
Call ResetAccess()
' volvemos a intentarlo
OnlyOnce = True
Resume
Else
MsgBox("Ha ocurrido un error imprevisto")
End If
Else
MsgBox("Error: " & Err.Number & vbCrLf & vbCrLf & Err.Description)
End If
Else
' por alguna razón esto no tira :-S
MsgBox("No se puede ejecutar el ejemplo")
End If
End Sub
' en este procedimiento exportamos el informe
' seleccionado en el ListBox
Dim ObjectType As Integer
Dim ReportName As String
Dim ExportFormat As String
Dim SNPFile As String
Dim OnlyOnce As Boolean
Dim Err As Object
If Me.AxListBox1.get_TopIndex > -1 Then
' tipo de objeto (acReport)
ObjectType = 3 'acOutputReport
' nombre del informe
ReportName = Me.AxListBox1.Text
' formato al que se exportará el informe
ExportFormat = "Snapshot Format (*.snp)"
' nombre y ruta del archivo que se exportará
SNPFile = oApp.Path & "\" & Me.AxListBox1.Text & ".snp"
On Error GoTo err_OutputTo
' exportamos el informe seleccionado al formato
' snapshot
oApp.DoCmd.OutputTo( _
ObjectType, ReportName, _
ExportFormat, SNPFile)
' cargamos el formulario donde se visualizarán los informes
Dim visua As New Form5()
visua.Show()
' le ponemos el nombre del informe que se mostrará
visua.Caption = "Informe: " & AxListBox1.Text
' vinculamos el archivo que hemos exportado con el visor
' de archivos Snapshot
visua.AxSnapshotViewer1.SnapshotPath = SNPFile
' eliminamos el archivo
Kill(SNPFile)
' mostramos el formulario
visua.Show()
' hacemos que el informe se ajuste al tamaño del formulario
visua.AxSnapshotViewer1.Zoom = SnapshotViewerControl.SnapZoom.snapZoomToFit
Else
MsgBox("Escoge un informe", vbExclamation, "Atención")
End If
Exit Sub
err_OutputTo:
If OnlyOnce = False Then
' si el formato snapshot no está disponible
If Err() = 2282 Then
' si se han podido cambiar las entradas erróneas del registro
If ChangeReg() Then
' reiniciaremos la aplicación Access para que los cambios
' surtan efecto
Call ResetAccess()
' volvemos a intentarlo
OnlyOnce = True
Resume
Else
MsgBox("Ha ocurrido un error imprevisto")
End If
Else
MsgBox("Error: " & Err.Number & vbCrLf & vbCrLf & Err.Description)
End If
Else
' por alguna razón esto no tira :-S
MsgBox("No se puede ejecutar el ejemplo")
End If
End Sub
1 respuesta
Respuesta de Roberto Alvarado
1