-
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
-
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
-
Do you know how to do this with a secured database?
-
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.
-
Sorry JonnyCab, I was asking Bigley if he knows, as I don't. :)