Solved

why doesn't GetDriveType(DrivetypeCode) work?

Posted on 2004-03-23
4
418 Views
Last Modified: 2008-03-17
Access 2000 XP
I get a '1' back as the DrivetypeCode regardless of whether its running on a local or networked computer.

Any suggestions how to use this or suggest new code to determine if the db is on a networed or local computer.

Thanks

Elton

'Check if this is a network drive
'Return  codes
'#####################
'The following codes are listed for reference
'  DRIVE_UNKNOWN = 0
'  DRIVE_ABSENT = 1
'  DRIVE_REMOVABLE = 2
'  DRIVE_FIXED = 3
'  DRIVE_REMOTE = 4
'  PDRIVE_CDROM = 5
'  DRIVE_RAMDISK = 6
'#####################
MsgBox GetDriveType(DrivetypeCode)
0
Comment
Question by:katzwhite
  • 2
4 Comments
 
LVL 23

Assisted Solution

by:heer2351
heer2351 earned 300 total points
ID: 10661468
Make sure you include a colon behind the drive letter, example:

MsgBox  GetDriveType("E:")
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 200 total points
ID: 10661496
Try this

Private Function CurrentDriveType() As String
    Dim fso As Object ' File System Object
    Dim drv As Object ' Drive
   
    Set fso = CreateObject("scripting.filesystemobject")
   
    Set drv = fso.GetDrive(fso.GetDriveName(App.Path))
    CurrentDriveType = Choose(drv.DriveType + 1, "Unknown", "Removable", "Fixed", "Network", "CD-ROM", "RAM Disk")
   
    Set drv = Nothing
    Set fso = Nothing
End Function
0
 
LVL 23

Accepted Solution

by:
heer2351 earned 300 total points
ID: 10661558
@capricorn1,

GetDriveType is an API function which does not require a scripting object.

Private Declare Function GetDriveType Lib "Kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

When you call this function without a colon behind the drive letter you do get a DRIVE_ABSENT (1) back all the time.
0
 

Author Comment

by:katzwhite
ID: 10662438
capricorn1 & heer2351,

You've both helped me understand the code (I'm not a very good VBA programmer).  I didn't understand I had to include the drive letter of the drive I needed checked, makes sense now.

I'm going to split the points.

Thanks for the help.

Elton
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 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