How do I view a selected Access report in Visual Basic? Any Code examples would be great...
VB Code: 'Add a reference to the Access X.X Object Library Option Explicit Private acc As Access.Application Private Sub Command1_Click() Dim view As Long Set acc = New Access.Application acc.OpenCurrentDatabase ("C:\TEST.mdb") acc.DoCmd.OpenReport "ReportName", acViewNormal 'acViewNormal means the report is just printed. acc.CloseCurrentDatabase Set acc = Nothing End Sub u have to find the constant to use instead of acViewNormal, but it should get u started
'Add a reference to the Access X.X Object Library Option Explicit Private acc As Access.Application Private Sub Command1_Click() Dim view As Long Set acc = New Access.Application acc.OpenCurrentDatabase ("C:\TEST.mdb") acc.DoCmd.OpenReport "ReportName", acViewNormal 'acViewNormal means the report is just printed. acc.CloseCurrentDatabase Set acc = Nothing End Sub
-= a peet post =-
VB Code: cmdPrintPreview_Click() Dim Axs As Access.Application Set Axs = CreateObject("Access.Application") Axs.Visible = True Axs.RunCommand acCmdAppMaximize Axs.OpenCurrentDatabase ("c:\YourPath\YourMdb.mdb") Axs.DoCmd.OpenReport "YourAccessReport", acViewPreview Axs.DoCmd.Maximize End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next Axs.Quit Set Axs = Nothing
cmdPrintPreview_Click() Dim Axs As Access.Application Set Axs = CreateObject("Access.Application") Axs.Visible = True Axs.RunCommand acCmdAppMaximize Axs.OpenCurrentDatabase ("c:\YourPath\YourMdb.mdb") Axs.DoCmd.OpenReport "YourAccessReport", acViewPreview Axs.DoCmd.Maximize End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next Axs.Quit Set Axs = Nothing
Forum Rules