Disable printing from standard menu

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi,

Is it possible to disable the "standard" print option from the menubar upon
form load and enable it on form exit?
If so, could you tell me how?

Txs in advance
Michael
 
Hi Michael

To disable the menu option:

Application.CommandBars("Menu Bar").Controls("&File") _
.Controls("&Print...").Enabled = False

Do this in the Form_Activate event procedure (unless the form is modal, in
which case use Form_Load).

To turn it back on, set it back to True in Form_Deactivate (or Form_Unload).
 
Txs Graham,

Works like a charm :-)

Michael

PS: Is there a way to disable the X (close window) of access itself to force
users to use the menu to close?

Graham Mandeno said:
Hi Michael

To disable the menu option:

Application.CommandBars("Menu Bar").Controls("&File") _
.Controls("&Print...").Enabled = False

Do this in the Form_Activate event procedure (unless the form is modal, in
which case use Form_Load).

To turn it back on, set it back to True in Form_Deactivate (or Form_Unload).

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Michael said:
Hi,

Is it possible to disable the "standard" print option from the menubar upon
form load and enable it on form exit?
If so, could you tell me how?

Txs in advance
Michael
 
Txs Graham,
Works like a charm :-)

You're welcome!
PS: Is there a way to disable the X (close window) of access itself to force
users to use the menu to close?

The simplest way is to add a module-level boolean to your main menu form:
Dim fOKToQuit as Boolean

and then add an unload event procedure to the form:

Private Sub Form_Unload(Cancel As Integer)
If Not fOKToClose Then
MsgBox "Please use the menu to exit"
Cancel = True
End If
End Sub

Then, any code path that calls Application.Quit should first set
fOKToQuit=True.

If you quit from some code outside your main menu form, then make the
variable Public in a standard module.
 
Perfect Graham,

Txs a lot!

Michael

Graham Mandeno said:
Txs Graham,

Works like a charm :-)

You're welcome!
PS: Is there a way to disable the X (close window) of access itself to force
users to use the menu to close?

The simplest way is to add a module-level boolean to your main menu form:
Dim fOKToQuit as Boolean

and then add an unload event procedure to the form:

Private Sub Form_Unload(Cancel As Integer)
If Not fOKToClose Then
MsgBox "Please use the menu to exit"
Cancel = True
End If
End Sub

Then, any code path that calls Application.Quit should first set
fOKToQuit=True.

If you quit from some code outside your main menu form, then make the
variable Public in a standard module.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand
 
Back
Top