Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Return Database Name (Access 97 SR-2)

    Hello all. I have, what I believe should be a pretty simple one...I am looking to display the saved name of the database (for example "2002 Database.mdb") on a form. Any ideas?

    Thanks in advance.

    Sean

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return Database Name (Access 97 SR-2)

    Use CurrentDb.Name to return the name and the path of the database.
    With the code in this thread you can retrieve the name without the path.
    Francois

  3. #3
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return Database Name (Access 97 SR-2)

    Forget the code for the Non Programmer:

    For the Path use:
    =Left([CurrentDb].[Name],InStr([CurrentDb].[Name],Dir([CurrentDb].[Name]))-1)
    as the control source for a calculated field on a form.

    For the Name use:
    =Dir([CurrentDb].[Name])
    as the control source for a calculated field on a form.

    For the programmer:

    Function getCurrentDBPath() As String
    getCurrentDBPath = Left(CurrentDb.Name, InStr(CurrentDb.Name, Dir(CurrentDb.Name)) - 1)
    End Function

    Function getCurrentDBName()
    getCurrentDBName = Dir(CurrentDb.Name)
    End Function

    FWIW

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •