Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call function from command button 1

Status
Not open for further replies.

Webkins

Programmer
Dec 11, 2008
118
US
I have put the following code in a Access 2003 module. It is to identify each drive in a computer. Now I cannot figure out how to call it from a command button. Any suggestions. Thank you all.

Public Function DExists(OrigFile As String)
Dim fs, d
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.driveexists(OrigFile) = True Then
Set d = fs.getdrive(OrigFile)
DExists = 1
If d.isready = True Then
DExists = 2
Exit Function
End If
Else
DExists = 0
End If
End Function
 
From where should come the OrigFile value ?
Where should go the return value of DExists ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am trying to identify a list of drives present in my computer at runtime
A starting point:
Code:
Sub ListDrives()
Dim FSO, dc, d
Dim S As String, N As String
Set FSO = CreateObject("Scripting.FileSystemObject")
Set dc = FSO.Drives
For Each d In dc
  N = ""
  S = S & d.DriveLetter & " - "
  If d.DriveType = Remote Then
    N = d.ShareName
  ElseIf d.IsReady Then
    N = d.VolumeName & " SN:" & Left(Hex(d.SerialNumber), 4) & "-" & Right(Hex(d.SerialNumber), 4)
  End If
  S = S & N & vbCrLf
Next
MsgBox S
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV. Your code works ABSOLUTELY beautiful and is so simple ! THANK YOU SO MUCH !

But now it seems that I have another problem. The code is reporting a CD/DVD drive (F:\) as being present which it is not. It even appears in the windows explorer as being present.

I am using a Dell laptop with a multi purpose drive bay. I have removed this CD/DVD drive and inserted a second hard drive. Why is this drive not totally removed from the system.
 
I have deleted this drive from the device manager control panel. It was loaded with a DVD-ROM emulator drive.

Is there any way to determine whether the drive is a CD/DVD drive ? Then I can just skip over this drive and continue the search ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top