Calling a Microsoft Access Report from Java

Posted on 2003-11-30
Last Modified: 2007-12-19
Anyone got any ideas or sites where I can try to find out how to call a Microsoft Access Report from a Java application?
Question by:imnotahomey
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
  • 2
  • +1
LVL 92

Expert Comment

ID: 9848047
think you're only option would be to start Access using Runtime.exec()

Author Comment

ID: 9848213
I need to pass parameters to the access report from my Java program. I would prefer not having to redo the entire report in another reporting tool.
LVL 92

Accepted Solution

objects earned 350 total points
ID: 9848222
Perhaps ask in the Access topic what command line you need to use to display your report. Then use Runtime.exec() to execute it.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 15

Expert Comment

ID: 9848632
hm...i suggest you to create dll in C++ or VB which is do everything you want with MS Access through COM model.
   Then use JNI mechanism to call dll functions from Java and pass parameters to it.

   Read JNI tutorial at to understand JNI

Expert Comment

ID: 9853435
create a shortcut to the report from access (this creates a shortcut file with a .mar extension I belive.  Then use Runtime.exec() and open that shortcut.  Then you open your report directly :)

Expert Comment

ID: 9853588
>>I need to pass parameters to the access report from my Java program.

I don't think you can pass info directly, but there is a way to do it.  Configure your report to pull whatever info you need from a table and use jdbc to pass info from your java app to your Access database.  Just use an Insert query.  If you need further explanation let me know.  I have been in this same predicament before.

After you have updated the table with the appropraite info, here is the command you can use to open the report (This worked for me with Access 2000 on a Windows XP machine)

Runtime load = Runtime.getRuntime();        
//open the file
load.exec("\"C:\\Program Files\\Microsoft Office\\Office\\MSACCESS.EXE\" /NOSTARTUP /SHELLSYSTEM [OpenReport \"C:\\Report.mar\",2]\"");

It looks confusing but basically this is the command your pc uses when you click on the report shortcut.

Author Comment

ID: 9855234
Thanks everyone for your help.
I found some answers in the Access topic thanks to objects
I will probably end up running the following command line that i got from Mr TextReport, which made me happy
"C:\Program Files\Microsoft Office\Office\MSAccess.exe" "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb" /x MacroName /CMD "[MyField]=5"

Function PrintReport
     docmd.openreport "MyReport", , Command$
End Function

and the macro does a runcode PrintReport()
LVL 92

Expert Comment

ID: 9855290

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

623 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