Board index » delphi » Previewing an Access Report through Delphi

Previewing an Access Report through Delphi

I am attempting to open a report from an MS Access database.  I have
accomplished this with the following code.  The problem is that it prints
immediately and I would like to preview it on the screen first.  From the MS
Access Help files I have found that there is an acViewPreview that is used
to do this, but I have not been able to get this to work properly.

procedure TMainForm.AccessReports;
Var MSAccess, RunReport : Variant;
begin
   MSAccess := CreateOleObject('access.application');

MSAccess.OpenCurrentDatabase('P:\0861\DEVELOP\ApplicantTrackingDBase.mdb');
   MSAccess.DoCmd.OpenReport('AVG TIME TO HIRE REPORT');
end;

Thanks for the help.

 

Re:Previewing an Access Report through Delphi


OpenReport have an additional parameter and there you can define a preview
mode (or design mode):
MSAccess.DoCmd.OpenReport('AVG TIME TO HIRE REPORT', acViewPreview,
EmptyParam, EmptyParam);
where
    acViewPreview = $00000002;

Anyway check my tip for this subject:
http://www.scalabium.com/faq/dct0083.htm

--
With best regards, Mike Shkolnik
E-Mail: mshkol...@scalabium.com
WEB: http://www.scalabium.com

Nancy Sorensen <nsoren...@bloomhealth.org> D???
???Y??:3cc857b4$1_1@dnews...

Quote
> I am attempting to open a report from an MS Access database.  I have
> accomplished this with the following code.  The problem is that it prints
> immediately and I would like to preview it on the screen first.  From the
MS
> Access Help files I have found that there is an acViewPreview that is used
> to do this, but I have not been able to get this to work properly.

> procedure TMainForm.AccessReports;
> Var MSAccess, RunReport : Variant;
> begin
>    MSAccess := CreateOleObject('access.application');

MSAccess.OpenCurrentDatabase('P:\0861\DEVELOP\ApplicantTrackingDBase.mdb');
Quote
>    MSAccess.DoCmd.OpenReport('AVG TIME TO HIRE REPORT');
> end;

> Thanks for the help.

Other Threads