Getting current application name without extension issues

NigelShaw

Registered User.
Local time
Today, 04:11
Joined
Jan 11, 2008
Messages
1,575
Hi Guys,

experiencing some strange issues. Lets say my application is this-

C:\Users\Nigel\Desktop\MyAccessApp.accdb

i need to retrieve "MyAccessApp" from it. i current use this-

Code:
Public Function ShortPath(strFullPath As String) As String
    ShortPath = Left(strFullPath, Len(strFullPath) - InStrRev(strFullPath, "."))
End Function
and i call it like this
Code:
strGetShortcutName = ShortPath(Application.CurrentProject.Name)
Problem is, the return i get is-
MyA
with the ccessApp missing!

ive tried it a few times now. Any ideas how to fix this?


cheers


Nidge
 
Here is one:
Code:
Function GetFileName(strFileAndPath As String) As String
    GetFileName = Mid(strFileAndPath, InStrRev(strFileAndPath, "\") + 1, InStrRev(strFileAndPath, ".") - InStrRev(strFileAndPath, "\") - 1)
    
End Function
 
Hi Bob,

that works a treat. Thanks very much :)

N
 
Nigel is mistaken CurrentProject.Name for CurrentProject.Path

Name will return MyAccessApp.accdb
Path will return C:\Users\Nigel\Desktop\MyAccessApp.accdb

So just replace".accdb"with "" to get the database name.
 

Users who are viewing this thread

Back
Top Bottom