Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling a Microsoft Access Report from Java

Posted on 2003-11-30
8
Medium Priority
?
748 Views
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?
0
Comment
Question by:imnotahomey
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 92

Expert Comment

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

Author Comment

by:imnotahomey
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.
0
 
LVL 92

Accepted Solution

by:
objects earned 1050 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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:dualsoul
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 java.sun.com to understand JNI
0
 
LVL 1

Expert Comment

by:sre23
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 :)
0
 
LVL 1

Expert Comment

by:sre23
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.
0
 

Author Comment

by:imnotahomey
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()
-------------------------
Boog.
0
 
LVL 92

Expert Comment

by:objects
ID: 9855290
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

885 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