FileDialog Anomaly

Giganews Newsgroups
Subject: FileDialog Anomaly
Posted by:  noodnutt (noodnu…@gmail.com)
Date: Sun, 9 Feb 2020

Hi Team

Just wondering if anyone else has seen this issue.

Friday just gone, I was using this same code to import .txt files. Today, I try and the File Open Dialog box is showing zero files in it, even though I can clearly see multiple .txt files in the same folder using the explorer.

Any thoughts please..??

TIA
Mark.

Option Compare Database
Const msoFileDialogFilePicker As Long = 3
Function GetFile()

    Dim myPath As Object
    Dim sFile As Variant

    With DoCmd
        .SetWarnings False
        .Hourglass True
    End With

    Set myPath = Application.FileDialog(msoFileDialogFilePicker)

    With myPath
        .AllowMultiSelect = False
        .Title = "Select your File"
        .Filters.Clear
        .Filters.Add ".txt Files", "*.txt"

        If .Show = -1 Then
            For Each sFile In .SelectedItems
                DoCmd.TransferText acImportDelim, , "tblImports", sFile, -1
            Next sFile
        Else
            sFile = "No File was Selected for Import."
            MsgBox sFile
        End If
    End With

    With DoCmd
        .SetWarnings True
        .Hourglass False
    End With

End Function

Replies