Results 1 to 3 of 3

Thread: Access 2000 VBA FileExists Function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    107

    Access 2000 VBA FileExists Function

    Can anyone tell me if it is possible to search for a file using the FileExists function that has a string with a wildcard?

    If FileExists("C:\Desktop\Graphic Images\" & "*" & myid & "*") = True Then

    myid contains an id#. The specific file name will vary for each record but should have the id# within the filename. I want to look for a file that is in Graphic Images folder but can start with any character, include the value of myid and end with any characters. The code above doesn't work.

    Thank you.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    Try this custom function which is called as per your code :-
    '=======================
    ' FileExists ?
    '=======================
    Public Function FileExists(fname) As Boolean
    Dim x As String
    x = Dir(fname)
    If x <> "" Then FileExists = True Else FileExists = False
    End Function
    '------------------------------------------------------------------------
    Regards
    BrianB
    -------------------------------

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    107
    Thank you for the response. The function I have works but it fails when I use the search string C:\Desktop\Graphic Images\" & "*" & myid & "*"). I'm not sure if I have a snytax error. Say I want to search for a file called J.Jones_123_125712.pic. The file would be under C:\Desktop\Graphic Images\. I want to search for it by using a wildcard *125712.pic. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width