Check and map Network drive

M

MarMo

Hi ,
Is there code in VBA to map a network drive like this :
"F:\Databses\Msaccess" where the F drive is on 1 of the servers.
I found code to check if the folder or drive exists , but i need to
reset the network drive if the mapping failed during computer
startup .
Thanks for your help
 
K

Kevin Smith

I know that this works in Excel so it should work in access but i have never
tried.

Shell "net use Z: \\s07445nts800uk\public /persistent:yes"

the "s07445nts800uk\public" is our server network location
 
J

Jack Leach

For the record, mapped drives tend to cause problems with development...
you'll want to use an API to get the actual UNC path for any programming
purposes

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
M

MarMo

Hello Jack,
I'm no expert in programming , but thanks for the info.
I already searched the net for some explanation
Thanks again
 
J

Jack Leach

This one should do the trick.

http://mvps.org/access/api/api0003.htm

I think if you change this function to public rather than private you should
be able to use it:

Private Function fGetUNCPath(strDriveLetter As String) As String

I forget the details, but apparently mapped drives are basically a leftover
from an earlier era... many vba functions fail when using a mapped drive, so
you'll want to replace the drive letter with the function from above. Maps
are great for a user interface (they make it pretty easy on the surface) but
on a deeper level they aren't all that wonderfull and take a lot of working
around. Many advise not to use them at all.

Anyway, just thought I'd throw it out there in case you weren't aware.

gl..

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top