Finding out the Pathname of the Current Database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In Excel's VBA I use a command to find out the path to the excel sheet I'm
using.
It goes along the lines of ThisWorkbook.Path

I was wondering if anyone knew of a similar command I could use in Access
VBA to get the directory path of the current database?

Ta.

Neil
 
Hi,

try this

function fctGetDBPath() as string
dim strReturn as string
strreturn = mid(currentdb.name,1, instrrev(currentdb.name,"\")
fctgetdbpath = strreturn
end function

Remember, MS DAO should be referenced!
 
Cheers,

That'll do it.

Ta.

Oliver Seiffert said:
Hi,

try this

function fctGetDBPath() as string
dim strReturn as string
strreturn = mid(currentdb.name,1, instrrev(currentdb.name,"\")
fctgetdbpath = strreturn
end function

Remember, MS DAO should be referenced!
 
Note, though, that InStrRev only exists in Access 2000 or newer, and in
those versions of Access, you can use CurrentProject.Path to get the same
thing.

In previous versions of Access, you can use

Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
 

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

Back
Top