UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetBEFolder    


Synopsis

There may be times when you need to find out the folder name where the BE is located. This simple function assumes that there's only one BE file and that it is an Access database.

CODE
' GetBEFolder
' http://www.utteraccess.com/wiki/GetBEFolder
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2013-09-25                    Returns the BE folder name for a linked Access table only
'
Public Function GetBEFolder() As String

Dim tdf As DAO.TableDef
Dim strConnect() As String
Dim strBEFolder As String
Dim lngIndex As Long

'Assume only one BE location
For Each tdf In CurrentDb.TableDefs
   If tdf.Connect > "" Then
       strConnect = Split(tdf.Connect, ";")
       For lngIndex = 0 To UBound(strConnect)
           If InStr(strConnect(lngIndex), "DATABASE=") > 0 Then
               strBEFolder = Replace(strConnect(lngIndex), "DATABASE=", "")
               strBEFolder = Left(strBEFolder, InStrRev(strBEFolder, "\"))
               Exit For
           End If
       Next
       Exit For
   End If
Next

GetBEFolder = strBEFolder

End Function

Creative Commons License
GetBEFolder by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 19,376 times.  This page was last modified 05:18, 29 September 2013 by TheDBguy.   Disclaimers