views:

818

answers:

5

I have created a report in MS Access report and write some VBA code to retrive data and show the report in MS-Word format. But while generate the report on runtime, the report first show or flash the report design view for few seconds and the report will get generated.

I would like to find a solution to avoid this flashing of design view while generate the report. Is it possible in this MS-Access or VBA coding. ??

I am posting the lines which i used to call the access report from access form code.

DoCmd.OpenReport rst![Argument], acPreview

this will generate the report but the design screen is flashing for few seconds while execution.

And there is no VBA code has been written in the access report.

The actual running is, i have prepare the data in a temp access table and generate the report from the table.

The problem here is, while launching the report in preview mode the design screen of the report shows of some few seconds. This looks bad from the users side.

+1  A: 

It seems you are opening the report in design view in order to change some property. It may be possible to avoid this, but you would need to post the code that opens the report to say for sure.

Remou
A: 

How are you exporting the report to MS-Word? What's the code?

Have you tried the same thing with a simple report (with a table data source) instead of using VBA code? Maybe the VBA is taking so long to run that it's holding the Report open in design mode long enough to be perceptible.

CodeSlave
A: 

What happens if you try this code:

  Dim strReport As Report        
  strReport = rst!Argument
  If SysCmd(acSysCmdGetObjectState, acReport, strReport) Then
     DoCmd.Close acReport, strReport
  End If
  DoCmd.OpenReport strReport, acPreview

What that code does is check to see if the report is already open in any view and then closes it if it is, then opens it. That insures that you're not in design view with the window hidden.

And the code also avoids any possible ByRef reference problems that might be associated with passing a value from a recordset to the OpenReport command.

David-W-Fenton
A: 

CodeSlave,

My guess is that the chinnagaja is exporting the report as an rtf file. Even though this is not a .doc, and does not support all formatting capability like underline or shading, it can be be opened with MS-Word.

I am very frustrated that MS-Access reports cannot be exported to a .doc file with all formatting retained. Surprised MS has not figured out and developed a way to do so after so many generations of Access

chinnagaja, please clarify how you are doing the export.

Mike

Mike
A: 

I have the same thing happen when I call a MS Access Report from a VB6 application. The reason it happens in my case is because I have a form set to appear at startup. If you don't have a startup form selected it should not become visible, therefore no flashing.

Let me know if this helps.

Mike