Solved

unavailable device

Posted on 2000-04-20
3
226 Views
Last Modified: 2010-05-02
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
Comment
Question by:WCOLEMAN01
3 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 70 total points
ID: 2734855

On Error goto trap
ChDrive "a:"

Trap:
Select Case Err.Number
Case 68

ChDrive "C:"
Case else
'Other error
End select
0
 

Expert Comment

by:Cuervo
ID: 2734864
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
 

Author Comment

by:WCOLEMAN01
ID: 2882092
Answer accepted
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now