By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,220 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,220 IT Pros & Developers. It's quick & easy.

How to handle CD and DVD drived in VBA?

P: n/a

Hi folks,

As part of a built in backup utility in our A3K app, we allow the user
to specify a drive letter on which to make a backup of the back-end
database. Only one problem,

If the user specifies a drive letter that equals a CD or DVD drive,
Access naturally croaks with what appears to be a non-trappable error
when we attempt to create a folder on the specified drive:

If Not IsFolder(backPath) Then
MkDir backPath
End If

Anyone know of a better way to handle this problem?

Thanks for all responses.

-- LW
Feb 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Lauren Wilson wrote in message
<lo********************************@4ax.com> :
Hi folks,

As part of a built in backup utility in our A3K app, we allow the user
to specify a drive letter on which to make a backup of the back-end
database. Only one problem,

If the user specifies a drive letter that equals a CD or DVD drive,
Access naturally croaks with what appears to be a non-trappable error
when we attempt to create a folder on the specified drive:

If Not IsFolder(backPath) Then
MkDir backPath
End If

Anyone know of a better way to handle this problem?

Thanks for all responses.

-- LW


I think I'd take a look at some of the objects, properties and methods
of the filesystemobject. These isn't popular in these NGs, as some
see them as security risks, some companies disable them ...

With a reference to Microsoft Scripting Runtime, you should be able to
do something like this

dim fs as scripting.filesystemobject
dim dr as scripting.drive

set fs = new scripting.filesystemobject
set dr = fs.getdrive(strYourDrive)

debug.print dr.isready, dr.drivetype

I think CD/DVDs have drivetype 4, but do observe that the IsReady
property will be true when a CD/DVD is in the drive and is accessible.
It doesn't tell you if you can write on it, but it should be able to
distinguish between different types of drives.

But doesn't just using a brute force method work under these
circumstances?

Either within your "IsFolder" method, or just before trying to create
the directory

on error resume next
dir (strDrive)
if err.number <> 0 then
' not accessible
end if
on error goto <your normal errorhandler>

--
Roy-Vidar
Feb 23 '06 #2

P: n/a
There is code at the Access web for determining the type of a drive.
--

Terry Kreft
"Lauren Wilson" <no****@nospam.com> wrote in message
news:lo********************************@4ax.com...

Hi folks,

As part of a built in backup utility in our A3K app, we allow the user
to specify a drive letter on which to make a backup of the back-end
database. Only one problem,

If the user specifies a drive letter that equals a CD or DVD drive,
Access naturally croaks with what appears to be a non-trappable error
when we attempt to create a folder on the specified drive:

If Not IsFolder(backPath) Then
MkDir backPath
End If

Anyone know of a better way to handle this problem?

Thanks for all responses.

-- LW

Feb 24 '06 #3

P: n/a
On Thu, 23 Feb 2006 10:53:35 +0100, "RoyVidar"
<ro*************@yahoo.no> wrote:
Lauren Wilson wrote in message
<lo********************************@4ax.com> :
Hi folks,

As part of a built in backup utility in our A3K app, we allow the user
to specify a drive letter on which to make a backup of the back-end
database. Only one problem,

If the user specifies a drive letter that equals a CD or DVD drive,
Access naturally croaks with what appears to be a non-trappable error
when we attempt to create a folder on the specified drive:

If Not IsFolder(backPath) Then
MkDir backPath
End If

Anyone know of a better way to handle this problem?

Thanks for all responses.

-- LW
I think I'd take a look at some of the objects, properties and methods
of the filesystemobject. These isn't popular in these NGs, as some
see them as security risks, some companies disable them ...

With a reference to Microsoft Scripting Runtime, you should be able to
do something like this

dim fs as scripting.filesystemobject
dim dr as scripting.drive

set fs = new scripting.filesystemobject
set dr = fs.getdrive(strYourDrive)

debug.print dr.isready, dr.drivetype


Thanks!
I think CD/DVDs have drivetype 4, but do observe that the IsReady
property will be true when a CD/DVD is in the drive and is accessible.
It doesn't tell you if you can write on it, but it should be able to
distinguish between different types of drives.
So the DriveType property is an integer? Is there a number to
standard name list available?
But doesn't just using a brute force method work under these
circumstances?

Either within your "IsFolder" method, or just before trying to create
the directory

on error resume next
dir (strDrive)
if err.number <> 0 then
' not accessible
end if
on error goto <your normal errorhandler>


As far as I know, a CD (or DVD) drive will report ready even if you
cannot write to it without using middle ware to do it. Unless I can
find a way to make use of the built-in WinXP CD writing features, I'd
just like to tell the user that the drive is not ready.

Mar 1 '06 #4

P: n/a
Lauren Wilson wrote in message
<fe********************************@4ax.com> :
On Thu, 23 Feb 2006 10:53:35 +0100, "RoyVidar"
<ro*************@yahoo.no> wrote:
Lauren Wilson wrote in message
<lo********************************@4ax.com> :
Hi folks,

As part of a built in backup utility in our A3K app, we allow the user
to specify a drive letter on which to make a backup of the back-end
database. Only one problem,

If the user specifies a drive letter that equals a CD or DVD drive,
Access naturally croaks with what appears to be a non-trappable error
when we attempt to create a folder on the specified drive:

If Not IsFolder(backPath) Then
MkDir backPath
End If

Anyone know of a better way to handle this problem?

Thanks for all responses.

-- LW

I think CD/DVDs have drivetype 4, but do observe that the IsReady
property will be true when a CD/DVD is in the drive and is accessible.
It doesn't tell you if you can write on it, but it should be able to
distinguish between different types of drives.


So the DriveType property is an integer? Is there a number to
standard name list available?


I think If you reference Microsoft Scripting Runtime, the help should
be
available (though I keep having problems with the A2K3 help). Here's a
link (watch for linebreak in the link)

http://msdn.microsoft.com/library/de...oDriveType.asp

I don't have any "pure" DVD station available, but it reports DriveType
4 for combined DVD/CD-ROM.

--
Roy-Vidar
Mar 1 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.