• Custom toolbar in report (A2K SR1)

    Author
    Topic
    #357444

    Hi,

    I have a database handling courses and students. There are lots of lists just needing to be printed out (no export etc.) implemented as reports. I would like to assign those reports custom toolbars/menu bars (Charlotte, thanx for the hint!) containing only the (hopefully) harmless commands. (Yes, I now too what users are able to, idiot or not :-))) ). The point is, I can’t find all the commands in the list if I open the Customize dialogue.

    It’s the commands “1 page”, “2 pages” etc. and a print command which brings up the normal printer dialogue I’m looking for. Users may want to print some lists in >1 specimens, or may want to choose economode or something. The only Print command I found is the shortcut for direct printing.

    And please, please don’t tell me I have to do all this via VBA – the deadline is already falling upon me like the dark shadow of Dracula …

    Viewing 0 reply threads
    Author
    Replies
    • #531032

      I know the SendKeys function is somewhat frowned upon, but I’ve successfully used Ctrl+P (^p) in a macro, then assigned the toolbar button to the macro.

      • #531558

        Hi Mark,

        thank you for replying. Yes, it would be so simple – only it didn’t work. I don’t know why, if I pressed ctrl+P, the printer dialogue came up all right, but clicking the custom command bar button just didn’t do anything. No dialogue, no error, nothing. After trying around, I turned back to VBA and ended up with this code (this was a hint in ADH in the discussion about command bars):

        Public Function PrintDialogue()
        
        On Error GoTo ErrPrintDialogue
        
        
           DoCmd.RunCommand acCmdPrint
        
        
        ExitPrintDialogue:
        On Error Resume Next
           Exit Function
        
        
        ErrPrintDialogue:
           Select Case Err.Number
              Case ERR_CANCEL_COMMAND	'Constant for command cancelled error 2501
        	'User klicked Cancel, do nothing
              Case Else
                 MsgBox CStr(Err.Number) & ": " & Err.Description, vbCritical+vbOKOnly, "Error in PrintDialogue"
           End Select
           Resume ExitPrintDialogue
        
        End Function
        

        Put that in a macro (executeCode), assigned the macro to the button and it works. I also have buttons for 1, 2, 4 pages preview.

    Viewing 0 reply threads
    Reply To: Custom toolbar in report (A2K SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: