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?
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?
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.