Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    26

    Unanswered: Importing a filename into Access

    I have managed to import data from an excel spreadsheet to the database, what I would also like to do is have the excel filename imported as well. Can anyone help me with this as I am really stuck on this one.

    Thank you in advance

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    How are you importing the file and what do you want to do with the filename?

    Post you code and I will modify it to meet you needs.

    Matt

  3. #3
    Join Date
    Jan 2004
    Posts
    26
    Sorry about that, I want to import the filename into a subform box called "Filename"

    Thanks

  4. #4
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Strip the filename out -


    ' in : Full File Path
    ' out : File Name
    ' example : [subform box].txt = GetName("C:\ExcelFiles\SomeFile.xls")

    Public Function GetName(strPath As String) As String
    Dim lg As Long

    On Error GoTo PROC_ERR

    lg = Len(strPath)
    Do
    lg = lg - 1
    If lg = 0 Then Exit Do
    Loop Until Mid(strPath, lg, 1) = "\" Or Mid(strPath, lg, 1) = ":"

    GetName = Left(Mid(strPath, lg + 1), Len(Mid(strPath, lg + 1)) - 4)

    PROC_EXIT:
    Exit Function

    PROC_ERR:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "GetName"
    Resume PROC_EXIT
    End Function

    -Matt

  5. #5
    Join Date
    Jan 2004
    Posts
    26

    Thumbs up

    Matt,

    thanks very much for your help. I can now successfully import the filename thanks to you.

    thanks again

Posting Permissions

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