Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Access - DB file path ?

Thread Tools
 
Search this Thread
 
Old 08 October 2003, 09:55 AM
  #1  
Jza
Scooby Regular
Thread Starter
 
Jza's Avatar
 
Join Date: Feb 2001
Posts: 2,959
Likes: 0
Received 0 Likes on 0 Posts
Question

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
Old 22 October 2003, 11:59 AM
  #2  
Jza
Scooby Regular
Thread Starter
 
Jza's Avatar
 
Join Date: Feb 2001
Posts: 2,959
Likes: 0
Received 0 Likes on 0 Posts
Post

bttt
Old 22 October 2003, 12:01 PM
  #3  
DemonDave
Scooby Regular
iTrader: (13)
 
DemonDave's Avatar
 
Join Date: Jan 2001
Location: Midlands - between notts and derby !
Posts: 4,997
Likes: 0
Received 0 Likes on 0 Posts
Arrow

What os ?

run a cmd line and type cd to that line

Dave.
Old 22 October 2003, 12:09 PM
  #4  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 22 October 2003, 12:10 PM
  #5  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

or even use importpath and import your file from there - oops!
Old 23 October 2003, 01:11 PM
  #6  
Jza
Scooby Regular
Thread Starter
 
Jza's Avatar
 
Join Date: Feb 2001
Posts: 2,959
Likes: 0
Received 0 Likes on 0 Posts
Post

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.....

Jza
Old 23 October 2003, 01:38 PM
  #7  
nkh
Scooby Regular
 
nkh's Avatar
 
Join Date: May 2002
Posts: 633
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 24 October 2003, 01:18 PM
  #8  
Jza
Scooby Regular
Thread Starter
 
Jza's Avatar
 
Join Date: Feb 2001
Posts: 2,959
Likes: 0
Received 0 Likes on 0 Posts
Post

What a total star !!!!!

Thanks m8!

Jza
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JimBowen
ICE
5
02 July 2023 01:54 PM
TylerD529
General Technical
2
09 October 2015 01:53 AM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
4
25 September 2015 09:55 PM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: Access - DB file path ?



All times are GMT +1. The time now is 04:15 AM.