• Return Database Name (Access 97 SR-2)

    Author
    Topic
    #367111

    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

    Viewing 0 reply threads
    Author
    Replies
    • #571538

      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.

      • #594708

        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

    Viewing 0 reply threads
    Reply To: Return Database Name (Access 97 SR-2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: