Hi,
I've got a VB6.0 sub that I want to open access reports selected from a treeview. I'm using the Access 9.0 Object Library to reference the report object. It kinda works, it generates the report but the access app does not stay open. I briefly see the report then access closes. Any suggestions would be appreciated. thanks
Private Sub TreeView1_DblClick()
Dim objAccess As Object
Dim strDbName, strReportName As String
If Left(TreeView1.SelectedItem.Key, 1) = "X" Then
strDbName = "E:\temp\db1.mdb"
strReportName = "Report1"
Set objAccess = New Access.Application
objAccess.OpenCurrentDatabase ("E:\temp\db1.mdb"
With objAccess
' Make Access visible and Preview report on screen
.Visible = True
.DoCmd.OpenReport strReportName, acViewPreview, ""
.DoCmd.Maximize
' Show Print Preview Toolbar
.DoCmd.ShowToolbar "Database", acToolbarYes
.DoCmd.ShowToolbar "Print Preview", acToolbarYes
End With
End If
End Sub
I've got a VB6.0 sub that I want to open access reports selected from a treeview. I'm using the Access 9.0 Object Library to reference the report object. It kinda works, it generates the report but the access app does not stay open. I briefly see the report then access closes. Any suggestions would be appreciated. thanks
Private Sub TreeView1_DblClick()
Dim objAccess As Object
Dim strDbName, strReportName As String
If Left(TreeView1.SelectedItem.Key, 1) = "X" Then
strDbName = "E:\temp\db1.mdb"
strReportName = "Report1"
Set objAccess = New Access.Application
objAccess.OpenCurrentDatabase ("E:\temp\db1.mdb"
With objAccess
' Make Access visible and Preview report on screen
.Visible = True
.DoCmd.OpenReport strReportName, acViewPreview, ""
.DoCmd.Maximize
' Show Print Preview Toolbar
.DoCmd.ShowToolbar "Database", acToolbarYes
.DoCmd.ShowToolbar "Print Preview", acToolbarYes
End With
End If
End Sub