Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

why doesn't GetDriveType(DrivetypeCode) work?

Posted on 2004-03-23
4
Medium Priority
?
424 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
[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
  • 2
4 Comments
 
LVL 23

Assisted Solution

by:heer2351
heer2351 earned 1200 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 800 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 1200 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

660 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