VB and VBA Users Source Code: Preview an Access Database Report
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Preview an Access Database Report
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, April 01, 2004
Hits:
2208
Category:
Database/SQL/ADO
Article:
The function below can be used to preview a report created in MS Access. 'Purpose : Preview an Access Report from VB 'Inputs : sAccessDBPath The path and filename of the access database containing the report to show ' sReportName The name of the report to show 'Outputs : Returns an empty string on success, else returns an error message. 'Author : Andrew Baker 'Date : 06/07/2003 'Notes : 'Example : 'Revisions : Function AccessShowReport(sAccessDBPath As String, sReportName As String) As String Dim oAccess As Object 'Access.Application On Error GoTo ErrFailed AccessShowReport = "" 'Create Access Set oAccess = CreateObject("Access.Application") 'Open Database oAccess.OpenCurrentDatabase sAccessDBPath 'Open report oAccess.DoCmd.OpenReport sReportName, 0 'acViewNormal 'Show Access Report oAccess.Visible = True oAccess.CloseCurrentDatabase Set oAccess = Nothing Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False AccessShowReport = Err.Description If oAccess Is Nothing = False Then oAccess.CloseCurrentDatabase Set oAccess = Nothing End If End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder