Jump to content

VBA Error Handling


Romany777

Recommended Posts

I have two instances that I would like to send to an error handler:

1. Select Query returns an empty dynaset - what object/property should I be checking and what should I be checking for?

2. I'm inserting images into a form - using OnError if the image file doesn't exist, I can pull in a generic image without any problem - HOWEVER - I would like the module to look in two (or more) places before calling in the generic image. I set OnError to goto a routine that looks for an image in the other place. The first statement in this routine is another OnError to goto the routine to pick up the generic image. If I remember correctly, it hangs in the second routine. What am I doing wrong?

Thanks!

Link to comment
Share on other sites

  • 2 months later...

Here is how we do this for #1:

If DLookup("[ID]", "Errorlog", "[ID] = 1") Then
objEmail.Textbody = "Report Log and Errorlog Attached for Report: " & MailBody 'Message body
objEmail.AddAttachment (stFileName) 'Attach Excel File
Else
objEmail.Textbody = "Update Report Log for: " & MailBody 'Message body
End If

For #2, you can use a IF..ELSE statement with an EXIST?

IF object.FileExists("C:\file1.bmp") Then
ELSE object.FileExists("C:\temp\file1.bmp")
END IF

Hope this helps.

Kent

Edited by kdyer
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...