Hi Ben
The Dir() function will return the full path name of a file if it exists,
otherwise it will return an empty string. It also works with wildcards, so
it can be used for your purpose to check for files whose names start with a
given string.
So, let's say you have a string variable "strFolder" that contains the full
folder path, including the trailing backslash, and you are loopng through a
recordset "rs" with a field named "Prefix". You can use code like this:
If Len(Dir(strFolder & rs!Prefix & "*") > 0 Then
' file starting with prefix exists
Else
' file starting with prefix does not exist
End If
--
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Ben" <(E-Mail Removed)> wrote in message
news:ec%(E-Mail Removed)...
> Hi all,
>
> I have a bunch of files in a directory and each are preceded by either a
> two character or three character prefix code to the file name. I have a
> table that contains these code, I obtained a record set of these codes by
> running a select query.
>
> Question:
> I would like to step through the recordset and compare each record (ie,
> the prefix code) and check to see if there in the directory, exists a file
> with the same prefix code. How do I check the directory for the
> existence of the file based on the prefix code in the recordset?
>
> Thanks,
>
> Ben
|