Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toolbar problem (Access 2000)

    Can you help me ? I wonder why my toolbar does not appear on the screen. In the OnActivate field of the report i have :
    ToolbarReports
    DoCmd.ShowToolbar "ToolbarReport", acToolbarYes
    And my codes in the modules section are :

    Sub ToolbarReports()
    On Error Resume Next
    Dim cbr As Object
    Dim cbb As Object
    ' msoBarTop = 1
    Set cbr = CommandBars.Add(Name:="ToolbarReport", Position:=1, Temporary:=True)


    ' msoControlButton = 1 First buton
    Set cbb = cbr.Controls.Add(Type:=1, Temporary:=True)
    With cbb
    .Caption = "My Button"
    ' msoButtonCaption = 2
    ' .Style = 2
    .FaceId = 41
    .Width = 60
    .FontWeight = 800

    .OnAction = "CloseTheReport"
    End With
    cbr.Visible = True
    Set cbb = Nothing
    Set cbr = Nothing

    End Sub


    Public Function CloseTheReport()
    DoCmd.Close
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar problem (Access 2000)

    There is no need to create the toolbar each time a report is activated, and no need to use code.
    Simply create the toolbar interactively (using Tools | Customize... in Access itself).
    Then set the Toolbar property of the report to the name of the toolbar. Access will automatically display the toolbar when the report is opened and hide it again when the report is closed.

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar problem (Access 2000)

    Thanks for the reply. I am sending the db to computers where i have no acces in order to arrange that manually.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar problem (Access 2000)

    If you design the toolbar interactively, it will be stored in the database, so it'll work OK on other computers too.

  5. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar problem (Access 2000)

    But how could i put my customized command, for example to close the report and open a form ?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar problem (Access 2000)

    You can assign the On Action property of a toolbar button interactively:
    - Select Tools | Customize...
    - Activate the Toolbars tab.
    - Click New...
    - Type a name, then click OK.
    - Activate the Commands tab.
    - Make sure that File is selected in the list of Categories on the left.
    - Drag Custom (the first item in the list of Commands on the right) to your new toolbar.
    - Right-click the new toolbar button.
    - Set its style, caption etc. the way you want.
    - Select Properties from the right-click menu.
    - Set the On Action property to =CloseTheReport()
    - Click OK.
    - Close the Customize window.
    - Hide (close) the new toolbar).
    - Open the report in design view.
    - Activate the Properties window.
    - Activate the Other tab.
    - Set the Toolbar property to the name of your custom toolbar (you can select it from the dropdown list).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •