Close a report in preview mode with VBA

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
 
G

Guest

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
 
A

Allen Browne

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

Guest

When using Docmd.RunCommand acCmdPrint the standard print
dialog box pops up, just like selecting File->Print from
the standard menu in MS-Office..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top