[AccessD] How To Stop Printing - Solved

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Mon Feb 3 23:42:00 CST 2003


Dear List:

I just wanted to gray out the print command on the file menu.  Here's the three lines I use to turn it off and on:

Dim cbc As CommandBarControl
Set cbc = CommandBars("Menu Bar").FindControl(ID:=4, recursive:=True)
cbc.Enabled = False

and 
Dim cbc As CommandBarControl
Set cbc = CommandBars("Menu Bar").FindControl(ID:=4, recursive:=True)
cbc.Enabled = True

Thanks for the input.  

Best

Rocky Smolin
Beach Access Software



  ----- Original Message ----- 
  From: jeffrey.demulling at usbank.com 
  To: accessd at databaseadvisors.com 
  Sent: Wednesday, January 29, 2003 1:21 PM
  Subject: Re: [AccessD] How To Stop Printing



  If you want you can hide the menu and toolbars with code like this on the Forms on open event 

  hideCommandBars 
  DoCmd.ShowToolbar "Unassigned_BM_Loans_Forms", acToolbarYes 
  DoEvents 

  Place this code in a module: 
  Sub hideCommandBars() 
      Dim cbr As CommandBar 
      For Each cbr In CommandBars 
          hidebar cbr 
      Next cbr 
  End Sub 

  Sub listbar(level As Integer, thisbar As CommandBar) 
      Dim cbrctl As CommandBarControl 
      Dim indent As Integer 
      ' Indent the command bar depending on its level in 
      ' the menu structure. 
      For indent = 1 To level 
          'MsgBox "   " 
      Next indent 
      Select Case thisbar.Type 
          Case msoBarTypeMenuBar 
              MsgBox "Menu Bar: " & thisbar.name 
          Case msoBarTypeNormal 
              MsgBox "Toolbar: " & thisbar.name 
          Case msoBarTypePopup 
              MsgBox "Popup: " & thisbar.name 
      End Select 
      For Each cbrctl In thisbar.Controls 
      ' If the control doesn't have a command bar associated 
      ' with it, then don't print it. 
          If cbrctl.Type <> 1 And cbrctl.Type <> 2 _ 
                And cbrctl.Type <> 4 And cbrctl.Type <> 16 _ 
                And cbrctl.Type <> 18 Then 
              listbar level + 1, cbrctl.CommandBar 
          End If 
      Next cbrctl 
  End Sub 
  Sub hidebar(thisbar As CommandBar) 
      Dim cbrctl As CommandBarControl 
      Dim indent As Integer 
      ' Indent the command bar depending on its level in 
      ' the menu structure. 
      'For indent = 1 To level 
          'MsgBox "   " 
      'Next indent 
      Select Case thisbar.Type 
          Case msoBarTypeMenuBar 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
          Case msoBarTypeNormal 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
          Case msoBarTypePopup 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
      End Select 
      'For Each cbrctl In thisbar.Controls 
      ' If the control doesn't have a command bar associated 
      ' with it, then don't print it. 
          'If cbrctl.Type <> 1 And cbrctl.Type <> 2 _ 
                And cbrctl.Type <> 4 And cbrctl.Type <> 16 _ 
                And cbrctl.Type <> 18 Then 
              'listbar level + 1, cbrctl.CommandBar 
          'End If 
      'Next cbrctl 
  End Sub 

  I also include the following in a module to get the menu and toolbars back: 
  Sub showdefaultbar() 
  DoCmd.ShowToolbar "Database", acToolbarYes 
  DoCmd.ShowToolbar "Menu Bar", acToolbarYes 

  End Sub 

  Hope this helps 



       "Rocky Smolin - Beach Access Software" <bchacc at san.rr.com> 
        Sent by: accessd-admin at databaseadvisors.com 
        01/29/2003 02:00 PM 
        Please respond to accessd 

               
                To:        AccessD at databaseadvisors.com 
                cc:         
                Subject:        [AccessD] How To Stop Printing 



  Dear List: 
    
  I have a user who, instead of printing the report which is attached to a button on a bound form, will hit the printer icon on the toolbar or click File-->Print and, of course, gets 200+ pages because it's printing all the records attached to the bound form.   
    
  He admits it's a bonehead thing to do but wonders if there's a way to prevent him from doing that (be serious, now). 
    
  Is there a way to stop that? 
    
  MTIA 
    
  Rocky Smolin
  Beach Access Software 
    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030203/ae4a926b/attachment-0001.html>


More information about the AccessD mailing list