Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 3rd, 2006, 02:48 PM
Registered User
 
Join Date: Apr 2006
Location: LONDON, , United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 10 problem

In chapter 10 I try to create the command bar and everything in code seems fine but when I run it I get the error message: run time error 5, invalid procedure call or argument. I have also added the office 11 object library. Can someone suggest a solution?

Sub CreateCommandBar()

Dim cbReport As CommandBar
Dim btnButton As CommandBarButton

'delete the command bar and if it does not exist, continue
On Error Resume Next
CommandBars("Wrox1 Report").Delete

On Error GoTo 0

'add the new command bar to the collection
Set cbReport = CommandBars.Add("Wrox1 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 custom 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.OnAction = "DisplayMessage"

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

End Sub

Sub DisplayMessage()

MsgBox "The new button was clicked."

End Sub
Reply With Quote
  #2 (permalink)  
Old August 5th, 2008, 08:54 AM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same error here (using the code downloaded from wrox.com), anyone got any ideas?

Reply With Quote
Reply


Thread Tools
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 problem rstoos Beginning PHP 1 September 16th, 2006 01:14 PM
Chapter 10 (P 367) Connection Problem sookarama BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 September 6th, 2006 07:59 AM
Chapter 10 login problem Dennis Mollet BOOK: Beginning VB.NET Databases 1 August 18th, 2005 04:07 AM
Chapter 10 Navigator.aspx problem jason88 BOOK: Beginning ASP.NET 1.0 0 May 27th, 2004 03:54 AM



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


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