Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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") _

'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") _

'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!

Reply With Quote
  #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

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

You have at the top : Dim btnButton As CommandButton

You should have : Dim btnButton As CommandBarButton

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

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

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 01:29 PM.

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