Listing names of files in folder on form

Anonymous
2020-06-11T01:02:31+00:00

I am having troubles trying to list on a form all files in a folder based on criteria.

I have tried both Allen Browne's solution and Daniel Pineault's solution, and they both seem* to work for ALL files in the folder.

What I need is the list to only show file names that start with a SKU # displayed in a text field ( [txtStockCode] ) on the form the listbox is on.

So something like - \folder\Archive BOM Copies\ & Me.[txtStockCode] & " *.htm "

For starters, would there be a better way to do this other than a listbox, like a sub-form?

If not, any ideas how I can filter the listbox based on what is in [txtStockCode] ?

Ultimately I want a clickable link to be able to open these files.

*I say seem to work as the file names that are displayed only show the name until there is a comma or parentheses in the file name. The files are saved to the folder as a concatenation of SKU+Description+Date(), and description commonly has comma's and occasionally parentheses. 

Also, it doesn't show all files in the list, there are ~2500 files in the folder and growing daily and it only scrolls down a few hundred. Maybe a non-issue as I only want it to be able to show the ones that match the text field.

Any help is appreciated, thanks!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

68 additional answers

Sort by: Oldest
  1. Anonymous
    2020-06-18T06:01:32+00:00

    Luckily we haven't had any virus cases here for a month so hopefully will stay that way

    That works really well... and fast. I only tried using a name as a part of a file name and seemed to work well. I couldn't get a result using something like *.pdf though

    Was this answer helpful?

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Anonymous
    2020-06-18T07:30:08+00:00

    My OneDrive folder at home isn't synching, so I had to reupload the latest file from my office computer. Here's the URL.

    Actually, it's working OK with general file type searches. I only added this tip on how to search for file types:

    • Tip:  to search for file types, just insert PDF, DOCX, etc. Don't do *.PDF, *.DOCX.

    If you wish to search for PDF's, just put in "PDF" and the whole name will be searched for that string. I can later add the capability to trap only DOC files so as not to get files with DOC within the actual name, s.a. "document56789.PDF".

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2020-06-18T08:18:49+00:00

    It does work really well and as i said, very fast. I'm sure this could be adapted for the Op very easily to meet his requirements.

    Only one small bug in the latest version:

    Private Sub Command67_Click()

    On Error Resume Next

    DoCmd.SetWarnings False

    DoCmd.RunSQL "SELECT tblWordDocuments.* INTO tblWordDocuments2 FROM tblWordDocuments WHERE InStr(1,[Link]," & Chr(34) & Me![Text5] & Chr(34) & ")<>0;"

    DoCmd.OpenForm "Handouts2"

    DoCmd.SetWarnings True

    Exit Sub

    End Sub

    should be frmHandouts2

    Was this answer helpful?

    0 comments No comments