Results 1 to 7 of 7

Thread: VB script in Acces

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    VB script in Acces

    Please help me out...

    On a network share I have pictures of employees. Name of picture is "<employeenumber>.gif".
    In Access I have a table containing employeenumber, full name etc.

    I like to have a query verify if every employee has it's own picture (why? Because it is used on an intranet). The output should contain the employeenumber and full name of persons without a picture.

    Now I tried something with:
    test: Len(([Dir$](('O:\picture\') & [employeenumber] & ('.gif')))).
    where "O:\picture" is the share on the network which contains the images and "employeenumber" is a field in a table.
    But this isn't working.

    What am I doing wrong?

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: VB script in Acces

    VB Code:
    1. Len(Dir("O:\picture\" & [employeenumber] & ".gif"))
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Re: VB script in Acces

    Thanks for the reply,

    I tried the suggested line, but now I get an error:
    Undefined function Dir.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: VB script in Acces

    where are you calling this???

    right in a Query?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: VB script in Acces

    ok.. well I guess u cant call dir in a query.. solution

    open a module and drop this in:

    VB Code:
    1. Public Function FileExists(sFile As String) As Boolean
    2.     If Len(Dir(sFile)) <> 0 Then
    3.         FileExists = True
    4.     End If
    5. End Function

    the u call it like this...
    FileExists("O:\picture\" & [employeenumber] & ".gif")

    it will return -1 if its there 0 if not...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Re: VB script in Acces

    Yes,
    This one worked.

    Thank you very much for assisting me.

  7. #7
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: VB script in Acces

    youre welcome




    please... click on thread tools > mark thread resolved. that way others know u have your answer. Thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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