Solved DriveExist error (1 Viewer)

The Rev

Registered User.
Local time
Yesterday, 19:45
Joined
Jan 15, 2003
Messages
118
Trying to see if a drive is mapped before I run some code on that drive path from my database. It may be empty so fileExists or FolderExists won't help. It's supposed to work simply, but I'm getting the" Object doesn't support this". Banging my head against the wall....

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.DriveExists ("R:\") Then
     Msgbox "R Drive mapped", vbOkOnly
End If

Why isn't it working?
 

June7

AWF VIP
Local time
Yesterday, 15:45
Joined
Mar 9, 2014
Messages
5,474
What happens - error message, wrong result, nothing?

The method works for me. If you want to provide a message for both results:

MsgBox "R Drive " & IIf(objFso.DriveExists("R:\"), "Mapped", "Not Mapped"), vbOKOnly
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:45
Joined
Oct 29, 2018
Messages
21,474
It works for me too. Which line is highlighted when you debug?
 

The Rev

Registered User.
Local time
Yesterday, 19:45
Joined
Jan 15, 2003
Messages
118
the DriveExists line is highlighted with the "Object doesn't support this property or method" error. I have Access on another PC and I put this code into a blank DB and it worked there. Just not on my laptop.
 

The Rev

Registered User.
Local time
Yesterday, 19:45
Joined
Jan 15, 2003
Messages
118
So somehow, a non-ASCII character got in my string for the drive letter. I deleted the line and retyped it and it now works. That was just strange...
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:45
Joined
Oct 29, 2018
Messages
21,474
So somehow, a non-ASCII character got in my string for the drive letter. I deleted the line and retyped it and it now works. That was just strange...
Glad to hear you got it sorted out. Cheers!
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:45
Joined
Sep 21, 2011
Messages
14,310
I wouldn't have thought you would have spaces in there either?
 

Users who are viewing this thread

Top Bottom