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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Answer accepted
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