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: Access 2010 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2010 Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison; ISBN: 978-0-470-59166-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2010 VBA Programmer's Reference 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 October 11th, 2011, 11:54 AM
JES JES is offline
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default Mailitem creation: runtime error 91

Hi --

Great book. Thanks for putting it together.

Question: I'm using code from Chapter 18, the 'Working with Outlook 2010' section beginning on p. 672. My problem is incredibly basic: I've included the reference to the Outlook 14.0 Object Library; I've copied-n-pasted the code exactly as printed; the code compiles cleanly. But when I actually invoke any of the subs or functions here -- e.g. CreateEmailWithOutlook() on p. 675 -- the code halts at the first non-declaration line:
Code:
Set olMailItem = olApp.CreateItem(olMailItem)
To say this is frustrating understates the case. :)

Thanks for any help!
Reply With Quote
  #2 (permalink)  
Old October 11th, 2011, 01:18 PM
gjgriffith's Avatar
Wrox Author
Points: 503, Level: 8
Points: 503, Level: 8 Points: 503, Level: 8 Points: 503, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 109
Thanks: 5
Thanked 14 Times in 14 Posts
Thumbs up You found an error!

Hello JES,

Thank you so much for reading the Access 2010 Programmer's Reference and for your extremely kind words about the book! Also, I wanted to say thank you so much for posting your question here, because there is actually an error in the code in this chapter of the book!

You said:
Quote:
But when I actually invoke any of the subs or functions here -- e.g. CreateEmailWithOutlook() on p. 675 -- the code halts at the first non-declaration line...
You are completely correct and there are some typos in this code. The correct code from Page 675 should actually be:
Code:
Public Function CreateEmailWithOutlook( _
    MessageTo As String, _
    Subject As String, _
    MessageBody As String)

    ' Define app variable and get Outlook using the "New" keyword
    Dim olApp As New Outlook.Application
    Dim objMail As Object ' An Outlook Mail item
    
    ' Create a new email object
    Set objMail = olApp.CreateItem(olMailItem)
    
    ' Add the To/Subject/Body to the message and display the message
    With objMail
        .To = MessageTo
        .Subject = Subject
        .Body = MessageBody
        .Display    ' To show the email message to the user
    End With

    ' Release all object variables
    Set objMail = Nothing
    Set olApp = Nothing

End Function
And, although you didn't specifically mention it here, the code on page 676 should actually be:
Code:
Public Function SendEmailWithOutlook( _
    MessageTo As String, _
    Subject As String, _
    MessageBody As String)

    ' Define app variable and get Outlook using the "New" keyword
    Dim olApp As New Outlook.Application
    Dim objMail As Object  ' An Outlook Mail item
 
    ' Create a new email object
    Set objMail = olApp.CreateItem(olMailItem)

    ' Add the To/Subject/Body to the message and display the message
    With objMail
        .To = MessageTo
        .Subject = Subject
        .Body = MessageBody
        .Send       ' Send the message immediately
    End With

    ' Release all object variables
    Set objMail = Nothing
    Set olApp = Nothing

End Function
This was actually one of my chapters in the book and I want to offer my deepest apologies for this mistake and thank you again for pointing it out so that we can get it fixed!

And if you have any other questions or need any other help here, please just let me know and I'll do what I can to help out.

Thanks,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->
Reply With Quote
  #3 (permalink)  
Old October 11th, 2011, 01:28 PM
JES JES is offline
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default Thank you!

Thanks so much for getting back to me, Geoff. This is actually spectacularly good news, because it means I'm not crazy (ha). I've been doing Access VBA since 2.0 but am always being surprised by how little I still know, and I just assumed I'd completely overlooked something obvious. (Edit to add: actually, now that I'm looking at it, it IS obvious!)

Appreciate the help, and again, appreciate the book very much. Best of luck with it!

John

Last edited by JES; October 11th, 2011 at 01:36 PM.
Reply With Quote
The Following User Says Thank You to JES For This Useful Post:
gjgriffith (October 11th, 2011)
  #4 (permalink)  
Old October 11th, 2011, 01:44 PM
gjgriffith's Avatar
Wrox Author
Points: 503, Level: 8
Points: 503, Level: 8 Points: 503, Level: 8 Points: 503, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 109
Thanks: 5
Thanked 14 Times in 14 Posts
Smile Thank You!

Hello John,

Thank you again for the extremely kind words about the book and for reading it! Again my deepest apologies for such a blatant mistake on my part and it is horrible that this code mistake made it into the book, obvious or not. And really, my only hope is that the book has been helpful to you (aside from this problem)! And if you have any other questions about the book, please just let me know and I'll do what I can to help out!

Thanks again,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->
Reply With Quote
  #5 (permalink)  
Old October 11th, 2011, 04:29 PM
JES JES is offline
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default Oh, by the way...

P.S. Geoff, the code from the book is reproduced verbatim in the Access 2010 Help documentation (and hence probably at the MS site) for the DoCmd.SendObject method. I have no idea how often they update that but it might be worth putting a bug in Microsoft's ear, too.
Reply With Quote
  #6 (permalink)  
Old October 19th, 2011, 03:50 PM
gjgriffith's Avatar
Wrox Author
Points: 503, Level: 8
Points: 503, Level: 8 Points: 503, Level: 8 Points: 503, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: Boulder, CO
Posts: 109
Thanks: 5
Thanked 14 Times in 14 Posts
Default Do you have the web page?

Hello John,

Thank you so much for the follow up here...some how I missed this note before?! Anyway, that is interesting, I did not realize the documentation on the Microsoft website was also incorrect. Do you have a link to the incorrect page on the Microsoft website? It would be a good idea to let them know if possible, but I'll need to know specifically which page you are referring to, because I'm not seeing it now (after a quick search).

Also, I wanted to thank you again for posting here and to let you know that we've fixed this error in our source code and have noted this problem on the errata page for the book at: http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html. Thank you SO MUCH for pointing out this mistake and helping us to get it fixed for other readers in the future! If there is anything else we can do to help out with this issue, please just let me know!

And thank you again for reading the Microsoft Access 2010 Programmer's Reference book, we truly appreciate it!

Thanks,
__________________
Geoffrey L. Griffith
http://www.ImagineThought.com

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->
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
Runtime Data-Reports Creation prajwalbro VB Databases Basics 0 October 17th, 2007 08:05 PM
Runtime error 91: Apjong Beginning VB 6 1 June 7th, 2006 09:47 AM
runtime error 91 Perseus Beginning VB 6 2 July 30th, 2005 04:36 AM
Ch4 Runtime Error 91 using db source code zip file Matrix_zero BOOK: Beginning Access 2003 VBA 0 March 1st, 2005 07:25 PM



All times are GMT -4. The time now is 12:36 AM.


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