Results 1 to 5 of 5

Thread: How To View Access Report Using ADO?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70

    Cool

    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

  2. #2
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284
    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

  3. #3
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565

    Question

    Do you know how to do this with a secured database?
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70
    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.

  5. #5
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Sorry JonnyCab, I was asking Bigley if he knows, as I don't.
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

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