Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning Access 2003 VBA
This is the forum to discuss the Wrox book Beginning Access 2003 VBA by Denise M. Gosnell; ISBN: 9780764556593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Access 2003 VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 13th, 2005, 06:27 PM
Registered User
 
Join Date: Oct 2005
Location: Garden Grove, Ca, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10

Is anyone having problems with adding the new CommandBar in Chapter 10 this is what I have and it comes back with "method or data not found" and the Style:
 Option Compare Database
Option Explicit

Sub CreateCommandBar()
Dim cbReport As CommandBar
Dim btnButton As CommandButton

'delete the command Bar and if it does not exist, continue
On Error Resume Next
CommandBars("Wrox Report").Delete
On Error GoTo 0

'add the new command bar to the collection
Set cbReport = CommandBars.Add("Wrox Report", msoBarFloating)

'add Zoom Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
    CommandBars("Print Preview") _
    .Controls("Zoom").Id)

'add 2 pages Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
    CommandBars("Print Preview") _
    .Controls("Two Pages").Id)

'add Copy Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
    CommandBars("database") _
    .Controls("Copy").Id)

'add a customer button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton)
    btnButton.Caption = "Test Button"
    btnButton.Style = msoButtonCaption
'list the name of the procedure to call when the button is clicked
btnButton.OnClick = "DisplayMessage"

'display the new command bar by setting visible
cbReport.Visible = True

End Sub

Sub DisplayMessage()

MsgBox "The new button was clicked"

End Sub
 Could someone help me!

  #2 (permalink)  
Old January 22nd, 2006, 09:41 AM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Denise got it right from what I can see - You've just doena couple of Typos !

a)
You have at the top : Dim btnButton As CommandButton

You should have : Dim btnButton As CommandBarButton

b)
You have towards the end :
btnButton.OnClick = "DisplayMessage"
You Should have :
btnButton.OnAction = "DisplayMessage"

c)
You may also need to make a reference to Microsoft Office 10.0 - or 11.0 or whatever you have in the Tools references - I've seen some Access set ups that don't have this ticked automatically

Hope this helps
Damien




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 - Ajax try it out VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 May 2nd, 2008 05:11 PM
Chapter 10: TreeView example postoak7 BOOK: Access 2003 VBA Programmer's Reference 0 September 19th, 2006 12:25 PM
Chapter 10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 March 29th, 2005 09:35 AM
Chapter 10 columbiasmiles JSP Basics 0 May 17th, 2004 08:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.