ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   Access - DB file path ? (https://www.scoobynet.com/computer-and-technology-related-34/257923-access-db-file-path.html)

Jza 08 October 2003 09:55 AM

Ok - i want to know the path to where the currentdb sits - so i can import a file in that directory (rather than hard code it as it may move around on our network).

Ive used

application.CurrentDb.Name

But this returns the silly 8bit file extension

"C:\TODAYS~1\StockExport.mdb"

If i then string out the StockExport.mdb bit - i thought i'd cracked it... but it then doesnt like the TODAYS~1

Any other way of finding the app path?

Jza

Jza 22 October 2003 11:59 AM

bttt

DemonDave 22 October 2003 12:01 PM

What os ?

run a cmd line and type cd to that line

Dave.

chiark 22 October 2003 12:09 PM

Don't hard code it, add another table called "configuration" with fields "name" and "value", then make an entry with values "export_path" and "c:\whatever\wherever\"

write your file to =dlookup("[value]","configuration", "[name]=""export_path""" & "data.mdb"

Any use?
Nick.

chiark 22 October 2003 12:10 PM

or even use importpath and import your file from there ;) - oops!

Jza 23 October 2003 01:11 PM

Thanks Nick... but i want to be able to copy the .mdb etc into any directory - and then it automatically know where to look without me having to do anything..... :eek:

Jza

nkh 23 October 2003 01:38 PM

Below is the code I am using to automatically link the database front end to the backend tables in another .mdb file. This works perfectly with long directory names.

---------------------
Private Sub Form_Load()
On Error GoTo Err_Form_Load

Dim db As Database
Dim ts As TableDefs
Dim t As TableDef
Dim path As String
Dim tstring As String


Set db = CurrentDb
Set ts = db.TableDefs

path = db.Name

If Len(path) > 4 Then
path = ";DATABASE=" & Left(path, Len(path) - 4) & "t.mdb"
Else
MsgBox ("error")
End If


For Each t In ts
If Not ((t.Name = "MSysAccessObjects") Or _
(t.Name = "MSysACEs") Or _
(t.Name = "MSysCmdbars") Or _
(t.Name = "MSysObjects") Or _
(t.Name = "MSysQueries") Or _
(t.Name = "MSysRelationships")) _
Then
t.Connect = path
t.RefreshLink

End If
Next


Exit_Form_Load:
Exit Sub

Err_Form_Load:

tstring = ""
For Each t In ts
If Not ((t.Name = "MSysAccessObjects") Or _
(t.Name = "MSysACEs") Or _
(t.Name = "MSysCmdbars") Or _
(t.Name = "MSysObjects") Or _
(t.Name = "MSysQueries") Or _
(t.Name = "MSysRelationships")) _
Then
tstring = tstring & t.Name & ", "

End If
Next
tstring = Left(tstring, Len(tstring) - 2)
path = Right(path, Len(path) - 10)
MsgBox "Please ensure " & path & " exists containing the following tables. " & tstring, , "Database or Table Missing"
DoCmd.Quit
Resume Exit_Form_Load
End Sub

Jza 24 October 2003 01:18 PM

What a total star !!!!!

Thanks m8!

Jza


All times are GMT +1. The time now is 04:40 PM.


© 2024 MH Sub I, LLC dba Internet Brands