PDA

Click to See Complete Forum and Search --> : How To View Access Report Using ADO?


JonnyCab
Nov 1st, 2000, 06:23 AM
Hi I am using VB6, Access97, and am trying to view reports using a ADO DataEnvironment.

I've tried the following code...

Public Sub OpenReport(rptName As String)

Dim objAccess As New Access.Application

objAccess.OpenCurrentDatabase (DataEnvironment1.Connection1)
Screen.MousePointer = vbHourglass
objAccess.DoCmd.OpenReport rptName, View:=acPreview
objAccess.DoCmd.Maximize
Screen.MousePointer = vbDefault
objAccess.Visible = True

...but get the error "Microsoft Access cant open the database because it is missing, or opened exclussively by another user."

I made sure the connection was not already opened... but still get the same error...any ideas?

Cheers Jonny

Bigley
Nov 1st, 2000, 07:22 AM
Set a reference to Microsoft Access object library

Private Sub Command1_Click()
Dim a As Access.Application

Set a = CreateObject("Access.Application")
a.OpenCurrentDatabase App.Path & "\NWind.mdb"
a.Visible = True
a.DoCmd.OpenReport "Catalog", acViewPreview
a.DoCmd.Maximize

End Sub

It doesn't use the data environment but it definately works

Stevie
Nov 2nd, 2000, 02:47 AM
Do you know how to do this with a secured database?

JonnyCab
Nov 2nd, 2000, 03:09 AM
No I don't Stevie...post some code if you have an example.

Thanks Bigley...I have used a similar method to the one you suggest but would still be interested to hear from anyone who knows how I use my DataEnvironment to open a Access report.... that way I only have one change to make should I change the location of the database.

Cheers everyone.

Stevie
Nov 2nd, 2000, 03:12 AM
Sorry JonnyCab, I was asking Bigley if he knows, as I don't. :)