Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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. OP
    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
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page