He encontrado este ejemplo:
Option Explicit
Dim oApp As Object
Private Sub Form_Load()
Dim db As Object
Dim con As Object
Dim doc As Object
Set oApp = GetObject(App.Path & "\Prueba.mdb")
Set db = oApp.CurrentDb
For Each doc In db.Containers("Reports").Documents
If Not doc.Name Like "Subinforme*" Then
Me.List1.AddItem doc.Name
End If
Next
Set db = Nothing
End Sub
Private Sub Command1_Click()
Dim ObjectType As Integer
Dim ReportName As String
Dim ExportFormat As String
Dim SNPFile As String
Dim OnlyOnce As Boolean
If Me.List1.ListIndex > -1 Then
ObjectType = 3 'acOutputReport
ReportName = Me.List1.Text
ExportFormat = "Snapshot Format (*.snp)"
SNPFile = App.Path & "\" & Me.List1.Text & ".snp"
On Error GoTo err_OutputTo
oApp.DoCmd.OutputTo _
ObjectType, ReportName, _
ExportFormat, SNPFile
Load Form2
Form2.Caption = "Informe: " & List1.Text
Form2.SnapshotViewer1.SnapshotPath = SNPFile
Kill SNPFile
Form2.Show
Form2.SnapshotViewer1.Zoom = snapZoomToFit
Else
MsgBox "Escoge un informe", vbExclamation, "Atención"
End If
Exit Sub
err_OutputTo:
If OnlyOnce = False Then
If Err = 2282 Then
If ChangeReg Then
Call ResetAccess
OnlyOnce = True
Resume
Else
MsgBox "Ha ocurrido un error imprevisto"
End If
Else
MsgBox "Error: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End If
Else
MsgBox "No se puede ejecutar el ejemplo"
End If
End Sub
Mi pregunta es como puedo hacer si la base de datos tiene pass, para que no me lo pida cada vez que haga un informe. Muchas gracias de antemano.