Link to home
Start Free TrialLog in
Avatar of WCOLEMAN01
WCOLEMAN01

asked on

unavailable device

I have a drive listbox and when I choose the a:\ drive I get an error saying unavailable device. I know that that is because I do not have anything in the drive. I just want some error handling to prevent the debug message. I would like the listbox to default to my c instead.  Can someone help?
ASKER CERTIFIED SOLUTION
Avatar of Dalin
Dalin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cuervo
Cuervo

Suppose we have a Drive combo called "Drive1" and a fileList called "File1" (that will change to the drive exposed in the "Drive1" control)

Check this code:

Private Sub Drive1_Change()

On Error Resume Next    'If there is an error, continue

File1.Path = Drive1.Drive

If Err.Number = 68 Then  'Check for an error
    MsgBox "Drive not prepared"
End If

End Sub

This will intercept the error number 68 (Drive not prepared) and display a message.

If you want to put a default drive to a drive listbox, use the Drive property:

drive1.drive="f:"       'Put the F: as default
Avatar of WCOLEMAN01

ASKER

Answer accepted