• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

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?
0
WCOLEMAN01
Asked:
WCOLEMAN01
1 Solution
 
DalinCommented:

On Error goto trap
ChDrive "a:"

Trap:
Select Case Err.Number
Case 68

ChDrive "C:"
Case else
'Other error
End select
0
 
CuervoCommented:
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
0
 
WCOLEMAN01Author Commented:
Answer accepted
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now