?
Solved

(Drive1.Drive) CD IN ??

Posted on 2001-08-29
4
Medium Priority
?
183 Views
Last Modified: 2011-08-18
Hi i am using Dir1.Path = Drive1.Drive to pas the selcted drive to a dir1 box

the problem is when i have no CD in mu CDrom bay and this is selected my prgram falls over ??

SILKI :o)
0
Comment
Question by:silki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6436904
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 200 total points
ID: 6436944
why not do something like this:

On Error GoTo NMEDIA
Dir1.Path = Drive1.Drive
Exit Sub
NMEDIA:
MsgBox "No Media in Drive!"
Drive1.Drive = Left(Dir1.Path, 2)
0
 
LVL 1

Expert Comment

by:atp_expert
ID: 6440401
Option Explicit
Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Command1_Click()
 Dir1.Path = IIf(SetCurrentDirectory(Left(Drive1.Drive, 2) = 0), Dir1.Path, Drive1.Drive)
End Sub

The setcurrentdirectory (api) will fail when, the directory or drive doesn't exits, so when u dont have a CD in ur drive, this api will fail, hence u can assign the previous drive.
0
 

Author Comment

by:silki
ID: 6440476
Simple yet effective !!

Thanx

SILKI
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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