Results 1 to 3 of 3

Thread: Access Report

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    72

    Access Report

    Hi everybody

    I am trying to get a report of ms access database(mdb database).


    code Code:
    1. Private cn As ADODB.Connection
    2.  
    3. Private Sub Command1_Click()
    4. Dim cn As New ADODB.Connection
    5. Dim acc As Object
    6. Set acc = CreateObject("Access.Application")
    7. Dim strDbName As String
    8. strDbName = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & App.Path & "\Pharmacy OP Ver 1.0.0.mdb "
    9. acc.OpenCurrentDatabase strDbName
    10. acc.DoCmd.OpenReport RptstaffDed, acViewPreview
    11. End Sub

    I am trying to connect it, but there is an error that comes
    "Microsoft Access can't open the database because it is missing or opened exclusively by another user, or it is not an ADP file.

    Can somebody point out my mistakes

    Please Help

  2. #2
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: Access Report

    Reread the error message...

    I would say that you need to close all instances of the DB. even if it's not visible... so goto Taskmanager and end the msaccess process.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Access Report

    You are trying to use ADO specific code against the Access Automation Server.

    The first argument to the OpenCurrentDatabase method is simply the path to the database. Don't specify Provider.

    The Provider is only required when you are connecting to a database thru ADO.

    Dim strDbName As String
    strDbName = App.Path & "\Pharmacy OP Ver 1.0.0.mdb "
    acc.OpenCurrentDatabase strDbName

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