Visual Basic Programming Code Examples Visual Basic > Database SQL Stuff Code Examples Preview an Access Database Report Preview an Access Database Report 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. 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