Full Path name of CurrentDb

A

Andy

If I use the code :-

Set dbsAdmin = CurrentDb
DBPath = dbsAdmin.Name

The full path name should be say, c:\Folder A\Folder B\Mydatabase.mdb but
DBPath contains c:\FolderA~1\FolderB~1\Mydatabase.mdb

It seems that for any folders in the path that contain spaces, the spaces
are removed and the "~1" suffix is added.

Is there a way to get the actual path name saved to variable DBPath?

Thanks.
 
B

bob

try using this code;

Dim dbs As DAO.Database
Dim strDBName As String
Set dbs = CurrentDb
strDBName = dbs.name

Bob Galway
 
W

Wayne Morgan

Which version of Windows are you running? You're getting the short name
version of the long file/folder names. In WinXP, I get the long version of
the name.
 
A

Andy

Wayne - I am running Access 97 on WinXP.

Wayne Morgan said:
Which version of Windows are you running? You're getting the short name
version of the long file/folder names. In WinXP, I get the long version of
the name.
 
A

Andy

Bob - I think your code is the same as mine except I didn't show the 2 Dim
statements in my question but I did have them in my code.
 
D

Douglas J. Steele

I believe it depends on how you open the database, Wayne.

If I recall correctly, if you open it by double-clicking on the file in
Windows Explorer, you'll get the short file name version. If you open
Access, then browse to it, you'll get the long file name version. This is
due to how the file association is set up in Explorer: generally it
specifies %1 as the argument being passed to msaccess.exe (where %1
represents the file name). Putting double quotes around that, like "%1"
should resolve it.
 
D

Douglas J. Steele

That IS the "actual path name". It just may not be the version you want!

For backwards compatibility, all files have both a LFN (long file name) and
a SFN (short file name). This is the way it's been in Windows since the
ability to use long file names was introduced in Windows 95.

http://www.mvps.org/access/api/api0020.htm at "The Access Web" shows how to
convert between the two.
 
A

Andy

Thanks Doug - Function fGetLongName worked fine.

Douglas J. Steele said:
That IS the "actual path name". It just may not be the version you want!

For backwards compatibility, all files have both a LFN (long file name) and
a SFN (short file name). This is the way it's been in Windows since the
ability to use long file names was introduced in Windows 95.

http://www.mvps.org/access/api/api0020.htm at "The Access Web" shows how to
convert between the two.
 
W

Wayne Morgan

I just tried opening by double clicking and I still got the long file name;
however, I do have the double quotes around %1 in my file associations.
 
B

Brendan Reynolds

I can't reproduce the problem either, but I do recall other people
mentioning it in the newsgroups in the past. Perhaps it depends on the
version of Access - or possibly the version of Windows? - in use?
 
D

Douglas J. Steele

I think you're right, Brendan. I know that my MRU in Access 97 gets a mix of
SFN and LFN. Since I never open files by double-clicking on them for Access
2003, I can't comment on whether it's an issue there.
 
A

Andy

Doug

Sorry to drag people back to this one but the Function fGetLongName has been
working fine with path names like c:\FolderA~1\FolderB~1\Mydatabase.mdb but
it doesn't work if the path name is a network path name like
\\machine1\share$\FolderA~1\FolderB~1\Mydatabase.mdb

The fgetLongName Function makes an api call to :-

Public Declare Function apiFindFirstFile Lib "kernel32" _
Alias "FindFirstFileA" _
(ByVal lpFileName As String, _
lpFindFileData As WIN32_FIND_DATA) _
As Long

apiFindFirstFile does not seem to like a path name starting with \\ instead
of a locally mapped path like c:\. It returns -1.

Any ideas? I just want to expand the path name to it's full glory in both
senarios above.

Thanks again.
 
T

TC

A

Andy

Thanks TC (is that Top Cat? - Great series)

The articles were useful.

I have made a change to the code presented at
http://www.mvps.org/access/api/api0020.htm to make it work for both Local
paths and Network paths. The code is originally designed for Local paths
starting with say, c:\ etc.

In function fGetLongName, the code strips out each part of the path
(separated by /) starting at the terminal filename and working backwards and
deals with any short names as it goes.
As the original code terminates, when it reaches the first 2 characters of
the path (say, c:), it checks for length of string <= 2 characters.

I have changed the code to check for the character ":" as last character or
"$" for network path (as our network paths have $ at end of share name). If
the network path did not use $ then I would suggest to amend code to count
the number of "\" characters (as in \\machine1\share) and check for count of
3 as well as checking for the ":" character.
 

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