Error Handling

K

KaiRich

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top