Print Page | Close Window

Get Path\Filename of Back End

Printed From: Roger's Access Library
Category: Other Download Libraries
Forum Name: Long, Crystal
Forum Description: Access Basics is designed for those of you with a thirst to understand the fundamentals of Access with programming in mind ... whether you realize it or not.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=616
Printed Date: 29 Mar 2024 at 4:57am
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Get Path\Filename of Back End
Posted By: Crystal Long
Subject: Get Path\Filename of Back End
Date Posted: 03 Nov 2013 at 11:00am
Given a table name, this function returns the path\filename of the Back End database if it is Access:

Function GetAccessBE_PathFilename(pTableName As String) As String
'strive4peace

   ' RETURN
   '  the file path and file name of the BE database
   '  "" if the table is not linked
  
   On Error GoTo Proc_Err
  
   Dim db As dao.Database _
      , tdf As dao.TableDef
  
   GetAccessBE_PathFilename = ""
  
   Set db = CurrentDb
   Set tdf = db.TableDefs(pTableName)
  
   If Len(tdf.Connect) = 0 Then
      GoTo Proc_Exit
   End If
  
   ' look at Connect string - Database Type is the first thing specified
   ' if the BE is Access
   If InStr(tdf.Connect, ";DATABASE=") <> 1 Then
      GoTo Proc_Exit
   End If
  
   GetAccessBE_PathFilename = Mid(tdf.Connect, 11)
   
Proc_Exit:
   On Error Resume Next
   Set tdf = Nothing
   Set db = Nothing
   Exit Function
 
Proc_Err:
   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   GetAccessBE_PathFilename"

   Resume Proc_Exit
   Resume
            
End Function


to test, you can type this into the Immediate window:
? GetAccessBE_PathFilename("MyLinkedTableName")

WHERE
MyLinkedTableName is the name of a table that is linked to an Access back end

Warm Regards,
Crystal

My Analyzer
... the ultimate Data Dictionary Tool (Free download. As of November 2013, last update was October 2013)
http://www.AccessMVP.com/strive4peace/Analyzer.htm#Download" rel="nofollow - http://www.AccessMVP.com/strive4peace/Analyzer.htm#Download

 *
   (: have an awesome day :)
 *



-------------
Warm Regards,
Crystal
Microsoft MVP
Remote Training & Programming
Let's Connect and Build Together

http://www.AccessMVP.com/strive4peace
http://YouTube.com/LearnAccessByCrystal
~have an awesome day ~



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net