Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 5th, 2004, 04:08 PM
iluvstrats iluvstrats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 iluvstrats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Function to return path of Currentdb

Is there a function that returns the path or directory of the CurrentDb?

Last edited by iluvstrats : February 5th, 2004 at 04:12 PM.

Reply With Quote
  #2  
Old February 6th, 2004, 10:55 PM
HFloyd HFloyd is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: New York, NY, USA
Posts: 1 HFloyd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Function to Get Path of CurrentDB

Dear iluvstrats,

Here is one I wrote awhile ago, I've added some comments and instructiuons for use at the top. I've never encountered any errors using this.

*NOTE* You will need a reference set for Microsoft DAO Object Library



Code:
Function ThisDB(Optional DesiredData As String = "fullpath") As String
'=================================================  ============================
'Copyright by Heather L. Floyd - Floyd Innovations - URL
' Updated 2-6-2004
'-----------------------------------------------------------------------------
' To return desired data about the current database file
'-----------------------------------------------------------------------------
' Parameters:
' ARGUEMENT                         :   DESCRIPTION
'-----------------------------------------------------------------------------
' DesiredData (Optional) (String)   :   String indicating what data you want
'                                       returned -
'                                       "fullpath" or "path" or "filename"
'                                       Default is "fullpath"
'-----------------------------------------------------------------------------
' Returns:
'   String of data requested based on 'DesiredData' arguement
'-----------------------------------------------------------------------------
' Example:
'-----------------------------------------------------------------------------
' ThisDB("fullpath") or ThisDB()= "C:\My Documents\My Database.mdb"
' ThisDB("path") = "C:\My Documents\"
' ThisDB("filename") = "My Database.mdb"
'=================================================  ============================

On Error GoTo ErrorCode


'Variables & values
    Dim db As DAO.Database
    Set db = CurrentDb()

    Dim strDB As String
    strDB = db.Name

    Dim strFullpath, strPath, strFileName As String
    strFullpath = strDB

    Dim iLenSDB As Integer
    Dim iDotLoc As Integer
    Dim iSlashLoc As Integer
    Dim strModSDB As String
    Dim iLenModSDB As Integer


    iLenSDB = Len(strDB)
    iDotLoc = InStr(strDB, ".")

    strModSDB = strDB
    iLenModSDB = Len(strModSDB)
    iSlashLoc = InStr(strDB, "\")

'Parse
    Do Until iSlashLoc = 0
        iLenModSDB = Len(strModSDB)
        strModSDB = Right(strModSDB, iLenModSDB - iSlashLoc)
        iSlashLoc = InStr(strModSDB, "\")
    Loop
    
    strFileName = strModSDB
    iLenModSDB = Len(strModSDB)
    strPath = Left(strDB, iLenSDB - iLenModSDB)

'Return value
    If DesiredData = "" Then
        ThisDB = strFullpath
    ElseIf DesiredData = "fullpath" Then
        ThisDB = strFullpath
    ElseIf DesiredData = "path" Then
        ThisDB = strPath
    ElseIf DesiredData = "filename" Then
        ThisDB = strFileName
    End If
    

ExitCode:
    Exit Function

ErrorCode:
    Select Case Err.number
        Case Else
            MsgBox "Error " & Err.number & ": " & Err.Description, vbCritical, "HLFFileUtils.ThisDB"
            Resume ExitCode
    End Select

End Function



Hope this helps.

Heather

Reply With Quote
  #3  
Old February 12th, 2004, 02:20 PM
iluvstrats iluvstrats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 iluvstrats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Function or command to return the path of an attached table?

Thanks. That worked great.

One more thing. Is there a function or command to return the path of of an attached table?

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Function to return path of Currentdb


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway