Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the directory where your MDB is 2

Status
Not open for further replies.

Jonathan

Programmer
Mar 19, 1999
116
0
0
GB
Hi,<br>
<br>
Is there any way of finding out where the current database MDB file is, ie the path name or similar?<br>
<br>
Thanks<br>
<br>
Jon
 
I use the following function, though there may be a built-in one through syscmd function, where p_tabname$ is the name of a table local to the mdb.<br>
<br>
Function ztablocation(p_tabname$) As String<br>
<br>
Dim l_db As Database, l_rs As Recordset<br>
Set l_db = CurrentDb()<br>
Set l_rs = l_db.OpenRecordset("Select Distinctrow MsysObjects.Database from MsysObjects where MsysObjects.Name = '" & p_tabname$ & "' and MsysObjects.Type =6", dbOpenSnapshot)<br>
If Not l_rs.EOF Then<br>
l_dbname = l_rs!Database<br>
Else<br>
l_dbname = l_db.Name<br>
End If<br>
l_rs.Close<br>
ztablocation = l_dbname<br>
End Function
 
I believe you could also use code that looks like this:<br>
<br>
Dim sVariable as String<br>
<br>
sVariable = DBEngine(0).Databases(0).Name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top