Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot run access report from c#

Posted on 2007-04-04
5
Medium Priority
?
563 Views
Last Modified: 2013-11-28
I am trying to preview an Access report using C# 2003.  I have this code which runs, but it doesn't do anything.  What am I missing?  

The overall goal is to get the report to open, then print to PDF using the acrobat driver save and close.
So far the code is opening the databse (non displayable) but does nothing else from what I can see.

                  Access.Application oAccess = null;

                  oAccess = new Access.ApplicationClass();
                  // Open a database in exclusive mode:
                  oAccess.OpenCurrentDatabase(
                        "C:\\db\\PV3.mdb" //filepath
                        ,false //Exclusive
                        ,""
                        );


                        oAccess.DoCmd.OpenReport(
                  "test", //ReportName
                  Access.AcView.acViewPreview, //View
                  System.Reflection.Missing.Value, //FilterName
                  System.Reflection.Missing.Value //WhereCondition
                  ,Access.AcWindowMode.acDialog
                  ,""
                  );
            MessageBox.Show("opened");
0
Comment
Question by:Delphinidae
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:stevbe
ID: 18852536
With the code you have now it is only opening the report in preview mode and doing nothing with it. So you wouldn't *see* anything unless you make access visible.

Not sure this has anything relevant but ... the access convention for passing argument values by name is ...

Argument:=Value

I'm not sure how translate that into C#.

another option would be to pass the arguments by position (to avoid the translation) and pass an empty string ("") for the *missing* arguments.

Let me see if I can fuind some code for printing to PDF, I am sure I have seen a question for that.

Steve
0
 

Author Comment

by:Delphinidae
ID: 18852566
The report is pulling from a SQL query in access.  What is happening is that the report does not display at all on my system.  This is what confuses me.  I would have thought the report should display in preview mode.
0
 
LVL 39

Accepted Solution

by:
stevbe earned 1000 total points
ID: 18852634
I think to see anything you are going to have to explicitly tell your access object to be visible

oAccess.Visible = True
0
 
LVL 39

Expert Comment

by:stevbe
ID: 18852639
here are a couple of links for PDF printing Access reports...

how to set the printer to PDF Printer in Access 2002 ...
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21218177.html?


how to print to pdf by setting the default printer to pdf distiller, also link for cutepdf (fereewaere) which you can basically do the same thing.
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21855703.html
0
 

Author Comment

by:Delphinidae
ID: 18852855
Thanks for your help... Next thing is to pass the pth to save the pdf file... This solved my initial question.   I just cannot believe I forgot to set visible to true.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question