Search and return files from folder on hard drive

S

snowbdr

We are nearly complete on a very dynamic database but we are clueless
as to how to search a file on the hard drive and return a list of
relevant files.

We would like to enter a few characters into a text box and then have
the db search a particular folder for that text string and return a
list of the matching files. Our file names vary in length so focusing
on the nth character from a certain point would not always return the
correct result.

Our filenames are something like "Fes_Sp_Agrogt_05Aug28" So, if a
particular piece of the filename must be parsed out then the most
appropriate method would be to search the characters between the 1st
and 2nd or 2nd and 3rd underscore.

Does anyone have any ideas?

Thank you in advance!!
 
W

Wayne Morgan

Try using the Dir() function to return all files in the folder. Check each
file name against your search parameter using the InStr() function. You
would first have to determine if the intent was for the search string to be
anywhere in the file name or if wild cards were used. If wild cards were
used, you could just pass the search string to the Dir() function since it
knows how to handle wild cards (i.e. * and ?).
 
Top