[AccessD] OT: Opening Access report from Visual Basic

MartyConnelly martyconnelly at shaw.ca
Tue Sep 23 22:11:26 CDT 2003


try this; close just some lines in wrong spot

Sub testreport()
Dim AccObj As Object
Dim db As Object
Dim dbPath As String
dbPath = "G:\SHARED\Productivity Reports\Oleg\db2.mdb"
  Set AccObj = CreateObject("Access.Application")
  Set db = AccObj.Application.DBEngine.Workspaces(0).OpenDatabase(dbPath)

      AccObj.Visible = True
      AccObj.OpenCurrentDatabase dbPath, False
      AccObj.DoCmd.OpenReport "Project Box Sheet", acPreview
      AccObj.Visible = True
      ' quit the application too if necessary
      'AccObj.quit
   Set db = Nothing
   Set AccObj = Nothing
   '
End Sub

Oleg_123 at xuppa.com wrote:

>Hi Group,
>
>I am trying to open an Access Report from Visual Basic form, doesn't seem
>to be working. I think that i used something like this in the past. (I
>checked Microst Access 9.0 Object library in references)
>
>Dim Acc As Object, db As Object
>Dim dbPath As String
>  Set AccObj = CreateObject("Access.Application")
>  Set db = AccObj.Application.DBEngine.Workspaces(0).OpenDatabase(dbPathName)
>
>dbPath = "G:\SHARED\Productivity Reports\Oleg\db2.mdb"
>      AccObj.OpenCurrentDatabase dbPath, False
>      Set db = Nothing
>      AccObj.DoCmd.OpenReport "Project Box Sheet", acPreview
>      AccObj.Visible = True
>
>
>-----------------------------------------
>Get Breaking News from CNN, ABC, NBC, CBS Now.
>http://www.xuppa.com/news/?link=webmail
>
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com
>
>  
>




More information about the AccessD mailing list