Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ACCESS REPORT IN DELPHI

Status
Not open for further replies.

hbez

Instructor
Mar 25, 2003
49
ZA
With ShellAPI one can certainly run an Access application from Delphi but, is it possible to run a report inside that Access db from inside the Delphi application?
 
That would require knowledge of the command-line parameters required to append to the command that launches Access.

To do this, in function ShellExecute(); the 3rd param (lpFile) must be an executable.

Your command-line parameter would be in the 4th param (lpParameters).

HTH

Roo
Delphi Rules!
 
I found the following code in several places on the net (Access is an Olevariant):
try
Access := GetActiveOleObject('Access.Application');
except
Access := CreateOleObject('Access.Application');
end;
Access.Visible := True;
Access.OpenCurrentDatabase('MyFinances.mdb', True); (a)
Access.DoCmd.OpenReport('rptHistory', AcViewPreview, EmptyParam, EmptyParam); (b)

I'm running into two problems:
Line (a) tells me that the db is missing or opened exclusively by another application.
Line (b) tells me 'You can't carry out this action at the present time'.
The db definitely exists and it has not been opened by another app - there is no ldb file that could lock the db.
Could somebody maybe tell me what the problem/s could be?
 
I've done this before, and my code looks pretty much like yours. I'm guessing that you need to add the path information to the database. ie.
Code:
Access.OpenCurrentDatabase('c:\MyFinances.mdb', True);

so that it finds it.
 
Thanks Griffyn, that worked, however, one problem remains: If I use
Access.DoCmd.OpenReport('rptHistory', acViewNormal, EmptyParam, EmptyParam);
the report immediately prints out A1OK. If I try acViewPreview (or 2), it seems to go thru the motions but the report is not displayed. Any ideas?
 
One more question please: What are the two emptyParam variables used for? In the query I use to generate a report, I have to input two dates. Can I use the SQL query as one of these two parameters to the two dates can be read from a DateTimePicker on my Delphi7 form?

Hannes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top