Results 1 to 7 of 7

Thread: Access Automation

Threaded View

  1. #1

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Access Automation

    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
    Last edited by mouse88; May 7th, 2009 at 03:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width