troubleshooting Question

List of PDF files in an ACCESS 2010 listbox

Avatar of Sandra Smith
Sandra SmithFlag for United States of America asked on
Microsoft AccessMicrosoft ApplicationsMicrosoft Development
5 Comments1 Solution1359 ViewsLast Modified:
How can I change the below to list only pdf?  What I tried did not work.

Sandra


Private Sub PopulateFileList()
'Populates the Files listing with files in the directory
    Dim strfileList() As String
    Dim strName As String
    Dim strPath As String
    Dim i As Integer
     'define the directory to be searched for files
    strPath = txtScanDirectory
    If Right(strPath, 1) <> "\" Then strPath = strPath & "\"

     'build a list of the files
    strName = Dir(strPath & "*.pdf")
   
    While strName <> ""
         'add fName to the list
        i = i + 1
        ReDim Preserve strfileList(1 To i)
        strfileList(i) = strName
         'get next filename
        strName = Dir()
    Wend
     'see if any files were found
    If i = 0 Then
        MsgBox "No files found"
        Exit Sub
    End If
     'cycle through the list and add to listbox
    For i = 1 To UBound(strfileList)
        Me.lstFiles.AddItem strfileList(i)
    Next
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros