Error Handling

  • Thread starter Thread starter Bradley C. Hammerstrom
  • Start date Start date
B

Bradley C. Hammerstrom

A2K,

No takers last week, so I'll reword the question:

My form has an image frame. The user can pick and save the image to be
loaded into the frame. The path and filename are stored in a table (it's
always a path to a photo CD).

If the user tries to open the form when the CD is not loaded, I want the
error to be handled with a dialog, "Please insert CD". Instead, the user
sees a default error dialog from Access about how it can't find the path,
which is a bit technical for the user.

Q: How can I override, or pre-empt, the standard default Access error dialog
and use my own in it's place?

Brad H.
 
Hi Brad,

I can help you with the error trap, but the routine I use
here to see if the CD is present is cumbersome.

First I will assume that since you want this to catch the
lack of CD in the Form_Load() event.
Second I will tell Access to catch this particular error
type and treat it specially.
(Note my CD drive on this PC is E:\)

Private Sub Form_Load()
On Error GoTo ErrorTrap
imgTest.Picture = "E:\Graphics\salogocl.gif"
imgTest.Picture = ""
ErrorTrap:
Select Case Err.Number
Case 2220: MsgBox "Please instert CD", vbOKOnly
Case Else: MsgBox "Unexpected Error", vbOKOnly
End Select
End Sub

I don't know how to get access to check if there is a CD
(I could do that in Excel without any trouble), so I try
and change the image to one from the CD (use a file you
know will exist), then change it back to either blank or
the default image - if the CD is present this should
happen so fast the user doesn't see anything (in Excel I
would turn ScreenUpdating off).

When I tried this the error was 2220, so this is the
Err.Number I trap for the 'insert cd' msg.

Hope this helps some.
Kai
 
Back
Top