Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar function

Status
Not open for further replies.

peljo

Technical User
Mar 3, 2006
91
BG
I wanted to build a toolbar function in the form, but after clicking on the button, in the form of an arrow, the error says that no such function exists. Where could the error be ?

Private Function ToolbarWar()

Dim cbr As Object
Dim cbb As Object
' msoBarTop = 1
Set cbr = CommandBars.Add(Name:="ToolbarWar", Position:=1, Temporary:=True)

Set cbb = cbr.Controls.Add(Type:=1, Temporary:=True)
With cbb
.Caption = "My Button"
.FaceId = 41
.Width = 60
.FontSize = 250

.OnAction = PRR
End With

End Function

Private Function PRR()
DoCmd.Close
End Function


 
Try:

Code:
Private Function ToolbarWar()

    Dim cbr As Object
    Dim cbb As Object
    ' msoBarTop = 1
    Set cbr = CommandBars.add(Name:="ToolbarWar", Position:=1, Temporary:=True)
      
    Set cbb = cbr.Controls.add(Type:=1, Temporary:=True)
    With cbb
        .Caption = "My Button"
       .FaceId = 41
       .Width = 60
       '.FontSize = 72
       
        .OnAction = "PRR"
    End With

End Function

Function PRR()
DoCmd.Close
End Function
 
The function needs to be declared as PUBLIC (not Private) so it is available throughout the project.


Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top