Results 1 to 13 of 13
  1. #1
    Join Date
    Dec 2004
    Posts
    277

    Unanswered: See if fileexists OnCurrent?

    Dim fso As IWshRuntimeLibrary.FileSystemObject
    Dim ref
    ref = Me.Reference

    If fso.FileExists("x:\Reference\" & ref & "\" & ref & "-pod.pdf") Then
    txtPOD.Caption = "Yes"
    Else
    txtPOD.Caption = "No"
    End If

    Any ideas?

    I am trying to check if a file exists on each record...

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    should work, but won't display on an unbound control using continuous forms due to an inherent design issue with Access

    now if you coul dpush the file test into a query then that may work....

  3. #3
    Join Date
    Dec 2004
    Posts
    277
    how would you recommend I do it in a query?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Not entirely sure you can, hence 'now if you could....' rather than thats what Id' do.....

  5. #5
    Join Date
    Dec 2004
    Posts
    277
    bumpin... anyone?

  6. #6
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Dump your code into a public function

    public function getfilefound(byval ref as string) as string

    Then call it from the query, passing the field where "ref" is stored.

    Note - if you need to pass Null, consdider declaring the parameter as variant.
    Roy-Vidar

  7. #7
    Join Date
    Dec 2004
    Posts
    277
    I don't understand what query to run

    could you explain more please?

  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    I was thinking it was the query you and healdem discussed. I got the impression you were discussing the recordsource for the form.
    Roy-Vidar

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Yup that'd probably work, if the function returned true/false on file found, it'll be a pig of a query to run mind you....

  10. #10
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    I agree, but often subform recordsets are small. Could probably better the performance a little by not instantiating the filesystemobject per each time the function was run, by declaring it as a public, then instantiate on form open or first run, and release in form close.
    Roy-Vidar

  11. #11
    Join Date
    Dec 2004
    Posts
    277
    sorry but I still don't understand...

    what query? how should i declare it public and what would that do...

    sorry lil slow..beginnin of the week and still before noon

  12. #12
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    If you are using an upto date version of Access (97 onwards) you can use the Office FileSearch facility. You would use code as:
    With Application.FileSearch
    .NewSearch
    .LookIn = "My Folder location"
    .SearchSubFolders = False
    .FileName = "*.xls" ' Change to any other type of wild cards
    .FileType = ' Select from the list of file types
    If .Execute Then
    For i = 1 To .FoundFiles.Count
    MsgBox .FoundFiles(i)
    Next I
    End If
    End With

    look in the help for further details about the syntax
    Justin

  13. #13
    Join Date
    Dec 2004
    Posts
    277
    Quote Originally Posted by justin_tighe
    If you are using an upto date version of Access (97 onwards) you can use the Office FileSearch facility. You would use code as:
    With Application.FileSearch
    .NewSearch
    .LookIn = "My Folder location"
    .SearchSubFolders = False
    .FileName = "*.xls" ' Change to any other type of wild cards
    .FileType = ' Select from the list of file types
    If .Execute Then
    For i = 1 To .FoundFiles.Count
    MsgBox .FoundFiles(i)
    Next I
    End If
    End With

    look in the help for further details about the syntax
    Justin
    this worked perfect

Posting Permissions

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