Solved

Cannot run access report from c#

Posted on 2007-04-04
5
556 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
  • 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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