Close a report in preview mode with VBA

  • Thread starter Thread starter Snurre
  • Start date Start date
S

Snurre

Hi ..

I have a code allowing users to choose printer for
printing a report. To do this, the report must be opened
in preview mode..But how do I close the report, it locks a
table when it's open, preventing other users to open a
report.

Dim stDocname As String

If Forms!bhr!StatusId = 5 Then
stDocname = "rBrevVentelisteEnkel"
With DoCmd
.OpenReport stDocname, acPreview
.RunCommand acCmdPrint
End With
End If

Snurre
 
Figured it out:

If Forms!bhr!StatusId = 5 Then
stDocname = "rBrevVentelisteEnkel"
With DoCmd
.OpenReport stDocname, acPreview
.RunCommand acCmdPrint
.Close acReport, "rBrevVentelisteEnkel"
End With

End If
 
Yes, the Close action is correct.

It's not clear how the users are selecting a printer.
Perhaps that happens in Report_Open or something.

If you are using Access 2002 or 2003, you can set the Printer object to
assign the printer to be used for a report. If you would like to give the
user the chance to choose a printer per report, and automatically use that
printer again next time they open that report, see:
Printer Selection Utility
at:
http://members.iinet.net.au/~allenbrowne/AppPrintMgt.html
Works with MDE/runtime.
 
When using Docmd.RunCommand acCmdPrint the standard print
dialog box pops up, just like selecting File->Print from
the standard menu in MS-Office..
 
Back
Top