Call Database Name

jkpats12

Registered User.
Local time
Today, 15:20
Joined
Jan 27, 2004
Messages
45
Hello,

Was wondering if anyone knew if there was a way to call the actual database name through a function ?

I want to use this code in a bunch of db's and did not want to have to enter the database name in each code, would just like to try & call the database name and place it in the code automatically.

Any help would be greatly appreciated.

Thanks
 
You can use CurrentDb.Name to get the name, or the below function to get the full path.

Function GetDBLocation() As String

Dim db As Database
Set db = CurrentDb

GetDBLocation = Left(db.Name, Len(db.Name) - Len(Dir(db.Name)))

Set db = Nothing

End Function
 
Thank you so much for your help !!
 
Acutally, I got that all wrong :-)

CurrentDb.Name will get you the full path of the db, including the name.

The function I posted will get you just the path of the db, without the name, but it could be easily modified to give you just the name.
 

Users who are viewing this thread

Back
Top Bottom