ms-accessreportdesignview

MS-Access reports shows design view upon execution


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.


Solution

  • 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.