Solved

why doesn't GetDriveType(DrivetypeCode) work?

Posted on 2004-03-23
4
407 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

919 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

19 Experts available now in Live!

Get 1:1 Help Now