When you build a custom menu bar in Microsoft Access 97 and include the built-in File menu, some commands do not appear on the menu in the run-time environment. For example, the Print command does not appear on the menu; as a result, you cannot modify the printer settings or properties. You can create a Microsoft Visual Basic for Applications function that displays the Print dialog box and attach that function to a custom Menu Bar. For more information see Article 173796 on the Microsoft Knowledge Base
'***************** Code Start ******************* 'Code from Microsoft Knowledge Base Public Function PrintOut() ' Attached to a custom Print command on a custom menu bar. ' Use the RunCommand method to display the print dialog box. On Error GoTo ErrorTrap DoCmd.RunCommand acCmdPrint Exit Function ErrorTrap: ' Check whether the RunCommand method was canceled. ' If RunCommand is canceled, it generates a trappable run-time error (2501). If Err.Number = 2501 Then Exit Function Else MsgBox Err.Number & vbCRLF & Err.Description End If End Function '****************** Code End ********************
Return to Example List