Here is my code which is supposed to open an access report for previewing rather than printing. For some reason when the code runs it kinda looks like it doing something for a few seconds butr nothing is displayed.
Can anyone advise why this is. This is the first time ive tried any automation of application so im not sure whats going wrong.
Code:Dim FileName As String = LoginForm.Filename Dim oAccess As Access.Application ' Start a new instance of Access for Automation: oAccess = New Access.ApplicationClass() Dim sDBPassword As String Dim oDBEngine As DAO.DBEngine Dim oDB As DAO.Database sDBPassword = "A5B7C5D8E4" 'database password oDBEngine = oAccess.DBEngine oDB = oDBEngine.OpenDatabase(Name:=FileName, _ Options:=False, _ ReadOnly:=False, _ Connect:=";PWD=" & sDBPassword) oAccess.OpenCurrentDatabase(filepath:=FileName, _ Exclusive:=False) Dim ReportName As String = "Autoglass Totals Report" oAccess.DoCmd.OpenReport(ReportName:=ReportName, View:=Access.AcView.acViewPreview) oDB.Close() System.Runtime.InteropServices.Marshal.ReleaseComObject(oDB) oDB = Nothing System.Runtime.InteropServices.Marshal.ReleaseComObject(oDBEngine) oDBEngine = Nothing




Reply With Quote