Close Preview Select Form

E

Emine

I have a form that allows you to select one or several reports for preview by
using a command button. I want the Form that has the selection of reports to
automatically close after I've hit the print button.

Here is my code. What Event Procedure do I use?

Private Sub Report_Open(Cancel As Integer)

Dim Bar As Office.CommandBar
Dim Ctrl As Office.CommandBarControl

For Each Bar In Application.CommandBars
If Bar.Name = "Print Preview" Then
Bar.Visible = True
For Each Ctrl In Bar.Controls
If TypeOf Ctrl Is Office.CommandBarButton Then
If Ctrl.Caption = "&Print" Then
' instead of using captions you may use
' Ctrl.ID = 2521
' but i don't if its the same ID in all
' Access versions.
Ctrl.OnAction = "DoPrint"
End If
End If
Next Ctrl
End If
Next Bar

End Sub

with

Public Sub DoPrint()
End Sub
 
M

MikeJohnB

By the way, you could put the code on the close event of the report, then
both the report and the form will be closed when completed.
 

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