Results 1 to 3 of 3
  1. #1
    E.Palmer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    2

    I would like to search folder using an Access field

    I have a bit of an odd problem I'm trying to solve. I'm using a database to gather information from a group of raters who will be looking at groups of photographs and giving them one of 4 classifications. The photographs are all named so that they can be searched via a unique number that is part of the file name - there are varying numbers of photographs for each subject. I have not placed these into the database, as we only need to capture the rating data and placing them all in there would be quite time consuming and extraneous (and from past experience prone to crashing the database). I put in a link on the form that opens the folder in which all of the photographs are stored- the raters could from there copy and paste the number into that window to search, but they'd prefer be able to skip that step and have my provided link return those search results.... is there any way I can do this? That unique number is field in my form, but I simply have not been able to find a way to create the search...



    One of the raters has suggested using the search string to create the link, which I can do, but that would mean I would have to create a new link for each record... which would also be extremely time consuming... I'd much rather do this automatically if I can - not to mention that it will also help avoid human error - ie. copying the wrong number over.

    Is there a better way?

    thanks!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you mean something like search for all files in the folder that have 12345 in the file name?

    that's pretty easy to do using filesystemobject commands. Especially if you have static folder names in a static directory structure.

    For instance if all of your image files are in the same folder as your database in a subfolder named 'photos' you could search the 'photos' subfolder
    Assume for the sake of argument you have a form with a text box named SEARCHSTR

    Code:
    dim fs
    dim fsFolder
    dim fsFile
    dim sFolder
    
    set fs = createobject("scripting.filesystemobject")
    sfolder = replace(currentproject.path & "\", "\\", "\") & "photos"
    set fsfolder = fs.getfolder(sfolder)
    for each fsfile in fsfolder.files
        sFileName = fsfile.name
        if instr(sfilename, SEARCHSTR) then
            debug.print sfilename
            'do whatever you're going to do with the file name here
        endif
    next fsfile
    
    set fsfolder = nothing
    set fs = nothing

  3. #3
    E.Palmer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    2
    Thank you. This is quite helpful.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 06-06-2019, 02:29 PM
  2. Replies: 4
    Last Post: 03-04-2019, 11:58 AM
  3. Access Search folder for excel
    By Chaser in forum Import/Export Data
    Replies: 2
    Last Post: 10-20-2017, 10:18 AM
  4. Replies: 8
    Last Post: 09-02-2015, 03:00 PM
  5. search for folder and return full path
    By eladz949 in forum Programming
    Replies: 3
    Last Post: 12-23-2012, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums