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 |
bttt
|
What os ?
run a cmd line and type cd to that line Dave. |
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. |
or even use importpath and import your file from there ;) - oops!
|
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 |
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 |
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