Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error handling (Access 97 / SR2)

    I have a function that emails a document using Outlook - if it is run a machine that hasn't got outlook installed, it crashes due to not having the proper reference available. It displays the error "User defined type not defined" and goes into debug mode.

    Is there a way of intercepting this error and just displaying the message "Cannot proceed, you do not have the correct software", or similar? (Or simply "Function failed" and exiting the function will do).

    Any help would be much appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Error handling (Access 97 / SR2)

    There are actually several methods. However, even having Outlook installed doesn't guarantee that you'll be able to send a message with it from Access, since it might not be set up for the current user.

    One of the ways around it is to use the CDO library and declare a MAPI session object, rather than using Outlook itself. That gets around the problem with figuring out *which* reference you need, since each version of Outlook has its own, uniquely named, object library. That's the method we use in our commercial applications, although that can break down to, since later versions of Office don't install Windows Messaging and CDO by default.

    If you're using a version of Outlook later than 97, there is a cheap dll called Redemption that is available for working with Extended MAPI calls, and gets around the security patches in Outlook 98 and later so you don't get those annoying "someone is trying to access your address book", etc., messages.

    Otherwise, you're going to have to write code that checks to see if the reference is broken and removes it if it is. You would also want to set a registry key or some kind of value to reference somewhere that will allow you to branch you code around any Outlook-based calls if the reference isn't there. You would probably use compiler #IF-#EndIfs to do that.
    Charlotte

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Error handling (Access 97 / SR2)

    Another problem I've found is that a missing reference like that can cause you problems, even if you don't try to e-mail! I use this to send an e-mail message (in which txtEmail contains the address).

    Application.FollowHyperlink "mailto:" & txtEMail

    This works regardless of email client user has.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Error handling (Access 97 / SR2)

    I can see where that would send a message, but what about the attachment?
    Charlotte

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Error handling (Access 97 / SR2)

    >>I can see where that would send a message, but what about the attachment?<<

    Oops, I guess I missed that. You know how it is when you read so many messages. Unfortunately, I have a habit of just skimming them (especially the longer posts) to try to pick-out the salient point. And sometimes I miss!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Error handling (Access 97 / SR2)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>That's OK, Mark. I have the same problem. I just thought maybe you knew a trick I had missed!
    Charlotte

  7. #7
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error handling (Access 97 / SR2)

    Thanks for your replies.

    Is there any way of setting references in code - the only solution I can think of is to get the user to select an email program when they start the database and set it up from there. Its either that or send two versions of the database out - after that, i'm out of ideas - not too good with .dll use yet!

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error handling (Access 97 / SR2)

    Look up the Reference object or the References collection in the online help for Access 97.
    Both have a link to an example that shows how to set a reference in code.

    But I'm afraid it would be a lot of work to get it all straight - perhaps more than it's worth.

    You'd have to loop through the references and check the IsBroken property.
    When you find a broken reference, you have to decide what it should be replaced by.
    Then remove the broken reference using the Remove method of the References collection.
    Add the correct reference using either AddFromFile or AddFromGUID.
    The AddFromFile method of the References collection requires the full path of the object library. This can be a problem. Some users might have installed Office in a custom location; they might have different versions of Outlook etc.
    For the AddFromGUID method, you have to look up the GUID of the object library in the Registry - not very pleasant.

  9. #9
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error handling (Access 97 / SR2)

    Thanks for your reply - see what you mean about a lot of work - I can see a thousand if isbroken = true statements (or something like that) coming my way if I take that route!
    I'm currently exploring the method of using docmd.sendobject and having it not quite as automated - hopefully the people using the database will be happy with that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •