Public Function PrintAccessReport(ByVal sReportName As String) As Boolean
PrintAccessReport = False
On Error GoTo ErrorHandler
'Dim acc As Access.Application
'Set acc = New Access.Application
Dim acc As Object
Set acc = CreateObject("Access.Application")
Dim db As DAO.Database
Dim strDbName As String
'Command2.Enabled = False
'strDbName = gsDataLocation & "\" & gsDBName
strDbName = App.Path & "\grp.mdb"
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName)
acc.OpenCurrentDatabase strDbName
acc.DoCmd.OpenReport sReportName, acViewPreview
'MsgBox "hello"
'acc.Application.DoCmd.PrintOut acPrintAll
'DoEvents
'acc.CloseCurrentDatabase
'db.Close
'Set db = Nothing
'Set acc = Nothing
'Success
PrintAccessReport = True
'MsgBox "Report has been Printed"
'Command2.Enabled = True
Exit Function
ErrorHandler:
MsgBox "An error occurred during the print of " & sReportName & " report." & vbCrLf & vbCrLf & "Notify MIS. Error " & Err.Number & " : " & Err.Description, vbCritical, "Unknown Error"
On Error Resume Next
acc.CloseCurrentDatabase
db.Close
Set db = Nothing
Set acc = Nothing
Exit Function
End Function