Results 1 to 20 of 66

Thread: Importing multiple txt files, but including extra data from file name

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Regular
    Joined
    Sep 2019
    Posts
    36
    Location
    I really appreciate the help. I may just be in over my head, I thought I changed what I was supposed to. The file names in the folder will be various customers and a date. Am I supposed to enter something into the blank quotations? Here is what I did.

    Sub ImportDailyBar()
    Dim FileNm, FilePathName, Path, FileNameList() As String
        Dim FileCount As Integer
        DoCmd.SetWarnings False
        Path = "C:\Users\dmaks\Desktop\Liquor Files\Bar Daily Sales"
        FileNm = Dir(Path & "")
        Search_path = Path ' where ?
        Search_Filter = "*.txt" ' what ?
        Docname = Dir(Search_path & "" & Search_Filter)
        Do Until Docname = "" ' build the collection
             MsgBox Docname
             FilePathName = Path & Docname
             DoCmd.TransferText transferType:=acImportDelim, TableName:="tblBarDailyData", FileName:=FilePathName, hasfieldnames:=True
             Docname = Dir
        Loop
        DoCmd.SetWarnings True
        MsgBox "Updates Complete"
        Exit Sub
        errorcatch:
        MsgBox Err.Description
    End Sub

    I really appreciate it.
    Last edited by Aussiebear; 02-09-2025 at 03:01 PM. Reason: Added code tags to supplied code

Posting Permissions

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