Current folder

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

Guest

How to automatically find path of database, in current folder?

I must put this in example:
Set dbs = OpenDatabase("C:\Documents and Settings\user\My
Documents\...\Database.mdb")

Thanks!
 
How are you defining "current folder"?

When you open Access (i.e.: open the program, as opposed to opening a
specific database), the current folder will be whatever was defined as the
Default Database Folder on the General tab under Tools | Options. If you
subsequently go to File | Open and navigate to a particular file, the folder
that file's in will become the current folder.

Perhaps you can explain what exactly your OpenDatabase statement is supposed
to be doing.
 
I use path of this folder in module.
I want relative path, same folder where database is.
This module put value from table to status bar.
Thanks!

Sub KojaMetoda(traziSto As String)
Dim dbs As Database
Dim rst As Recordset
Dim varBookmark As Variant
Set dbs = OpenDatabase("C:\Documents and Settings\user\My
Documents\...\Database.mdb")
Set rst = dbs.OpenRecordset("tblMetode", dbOpenDynaset)
traziMet = ""
With rst
.MoveLast
.MoveFirst
Do While True
If rst.Fields(1).Value = traziSto Then
traziMet = rst.Fields(2).Value
Exit Do
End If
.Move 1
If .EOF Then
.MoveFirst
traziMet = "Undeffined method"
Exit Do
End If
Loop
End With
rst.Close
dbs.Close
End Sub

Sub MsgBar(msg As String) '*** Display message in status bar ***
RetVal = SysCmd(acSysCmdSetStatus, msg)
End Sub
 
To get the folder where the current database is located, look at
CurrentProject.Path (or Left(CurrentDb.Name, Len(CurrentDb.Name) -
Len(Dir(CurrentDb.Name))))
 
Back
Top