Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Printing Report from Disconnected Project with SQL Server Data

Discussion in 'Information Technology' started by dougloj, Oct 28, 2005.

  1. dougloj

    dougloj
    Expand Collapse
    Guest

    I have a disconnected Access 2003 project (adp)that I use to access an
    SQL Server 2000 database. I open and close the connection from the
    project to the database to get and store data as needed in the project
    with no problem.

    Can anyone tell me how to print a report within the project VBA code
    using data from the database?

    I've tried the folling code :

    Set conn = New ADODB.connection
    conn.ConnectionString = <connection string info ...>
    conn.Open
    conn.CursorLocation = adUseClient
    DoCmd.OpenReport stDocName, acNormal
    conn.Close

    When I run this code, I get an error which says:

    "Access was not able to perform this operation because the project is
    not connected to a SQL Server database."

    Any ideas would be welcomed!

    Thanks for the bandwidth.

    - Doug
     
  2. Loading...

    Similar Threads Forum Date
    Controversial War over Private Printing of "Birs" Intensifies Hard Talk Jul 9, 2011
    UK British Sikh Report-2016 Breaking News Mar 24, 2016
    1984 The Story I Did Not Report In ’84 History of Sikhism Jun 28, 2015
    Opinion Top Green Beret Officer Forced to Resign Over Affair With WaPo Reporter Breaking News Jun 26, 2014
    United Sikhs New Report Shows Increasing Hate Attacks on Sikhs Sikh Organisations May 21, 2014

  3. Norman Yuan

    Norman Yuan
    Expand Collapse
    Guest

    Your code (opening/closing an ADODB.Connection) does nothing: open
    connection and then close it. The DoCmd.OpenReport() method uses
    CurrentProject.Connection to perform data accessing. Since your adp is
    disconnected, your report will not run, of course.

    If you have to use the code to connect the ADP for opening the report and
    then disconnect the adp afterward, you can use
    CurrentProject.OpenConnection()/CloseConnection() method, something like:

    CurrentProject.OpenConnection connectionString
    DoCmd.OpenReport .............
    CurentProject.CloseConnection

    (I never tried this, not sure it will work or not, though).

    "dougloj" <dougloj@comcast.net> wrote in message
    news:1130444912.702030.23950@z14g2000cwz.googlegroups.com...
    >I have a disconnected Access 2003 project (adp)that I use to access an
    > SQL Server 2000 database. I open and close the connection from the
    > project to the database to get and store data as needed in the project
    > with no problem.
    >
    > Can anyone tell me how to print a report within the project VBA code
    > using data from the database?
    >
    > I've tried the folling code :
    >
    > Set conn = New ADODB.connection
    > conn.ConnectionString = <connection string info ...>
    > conn.Open
    > conn.CursorLocation = adUseClient
    > DoCmd.OpenReport stDocName, acNormal
    > conn.Close
    >
    > When I run this code, I get an error which says:
    >
    > "Access was not able to perform this operation because the project is
    > not connected to a SQL Server database."
    >
    > Any ideas would be welcomed!
    >
    > Thanks for the bandwidth.
    >
    > - Doug
    >
     

Share This Page