Tell access to use the current directory

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

I have a file OpenFile.mde that opens another file mdb that has is password
protected.

Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\Acct\Access\GLFile.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=pwd")
acc.OpenCurrentDatabase strDbName

Question: Instead of saying "C:\Acct\Access\GLFile.mdb" How do I say just
use the directory you are currenly in (ie the OpenFile.mde and GLFile.mdb are
in the same directory?

Thank you,

Steven
 
Realistically, you can seldom be sure of what the current directory is (it
won't be the same directory as the currently-open database unless you opened
Access and used File | Open to navigate to the database).

However, you can easily determine where the currently-open database is using
CurrentProject.Path:

strDbName = CurrentProject.Path & "\GLFile.mdb"

(Note that the Path property does not include the terminating slash, so you
need to add it to the file name.)
 
Steven said:
I have a file OpenFile.mde that opens another file mdb that has is password
protected.

Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\Acct\Access\GLFile.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=pwd")
acc.OpenCurrentDatabase strDbName

Question: Instead of saying "C:\Acct\Access\GLFile.mdb" How do I say
just
use the directory you are currenly in (ie the OpenFile.mde and GLFile.mdb
are
in the same directory?

Thank you,

Steven

strDbName = CurrentProject.Path
 
Back
Top