Results 1 to 15 of 15
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File System Object - folder in use (2000/XP)

    I'm modifying some code which uses the FileSystemObject to check a folder and image path then sets the .Picture property of an Image control accordingly. This happens in the OnCurrent event of a form.

    I closed the form and tried to rename the folder in windows explorer to check my error catching but get a message saying the folder is in use.

    This is what I'm doing

    Declaring it: Dim FSO As Scripting.FileSystemObject

    Setting new before use: Set FSO = New Scripting.FileSystemObject

    Used to check folder exists: If FSO.FolderExists(strExamFolder) Then 'do something

    Used to check image exists: If FSO.FileExists(strImageIncPath) Then 'do something

    before exiting: Set FSO=Nothing

    Any ideas why my db is hanging on to the folder?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    Is this a network folder? If so, try to do the same with a folder on your hard disk. Do you get the same error?

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Hi Hans

    No my test folders are on my C drive. I just notice that if I use the form to set the picture for another record (and folder) I can rename the folder that was previously locked. The folder I've just accessed through code if the one now locked.

    Actually ignore that. i've just been testing again and the behaviour is inconsistent.

    I have checked and anywhere an object called FSO is created it is definitely set to nothing within the routine.

    Should Set FSO=Nothing do the trick or am I missing something? <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    What happens if you just set the picture, without using any FileSystemObject code? Is the folder containing the "current" picture still locked?

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Fully refreshed after the weekend I think I've figured this out.

    I don't think there is anything wrong with my code using the File System Object. I've been opening the form on different records (so different pictures and different folders). The form OnCurrent event uses the FSO object to test the existent of the folder and file each time.

    The problem (folder in use message in Windows explorer if I try to manually rename a folder) seems to occur only after I have actually browsed for a picture. Therefore, I think the 'problem' is wrapped up in the code that calls the common dialog.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Just when I thought I was sorted, I've just noticed something else.

    When I preview the corresponding report (which makes the same checks) each record displays the correct picture but if there isn't one yet that record displays the last picture <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    If there is no photo name in the appropriate field (or if the there is a problem with the folder of file) I'm setting the image .picture property as follows:

    Me.imgOverViewPhoto.Picture = "" (or bVbNullString)

    (this is done in the Detail_Format event for the report)

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    That should work. Could you post the complete Detail_Format code?

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    This isn't the entire code but is the relevant section in full
    (all variables have been declared).

    strImageIncPath is the file name (stored in a field) prefixed by the path (derived - and working)

    If FSO.FileExists(strImageIncPath) Then
    Me.imgOverViewPhoto.Picture = strImageIncPath
    Else
    blnNoPhotoDisplayed = True
    strPhotoProblem = "The file '" & Me!txtPhotoName.Value & "' was not found in '" & strFolder & ".'"
    End If

    If blnNoPhotoDisplayed Then
    Me!lblPhotoProblem.Visible = True
    Me!lblPhotoProblem.Caption = strPhotoProblem
    Me.imgOverViewPhoto.Picture = vbNullString
    Else
    Me!lblPhotoProblem.Visible = False
    Me!lblPhotoProblem.Caption = ""
    End If

    I'm setting a caption to display the problem - this works - but the image shows the picture used for the last record that had one.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    I would hide the image control if there is no valid picture:

    If blnNoPhotoDisplayed Then
    Me!lblPhotoProblem.Visible = True
    Me!lblPhotoProblem.Caption = strPhotoProblem
    Me.imgOverViewPhoto.Picture = vbNullString
    Me.imgOverViewPhoto.Visible = False
    Else
    Me!lblPhotoProblem.Visible = False
    Me!lblPhotoProblem.Caption = ""
    Me.imgOverViewPhoto.Visible = True
    End If

  10. #10
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Should the .picture =vbNullString or = "" have worked in the context I'm using it?

    I was just thinking of hiding the image control if I couldn't figure out how to clear it.

  11. #11
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    I have a feeling it should be the empty string ("") rather than vbNullString.
    <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17>Try it and see!
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    No, I just tested it in one of my own databases. I commented out the instruction to hide the image control, and indeed, setting the Picture property to "" doesn't work. So you really do need to hide the control.

  13. #13
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Quote from Help (A2003)

    "The default setting is (none). After the graphic is loaded into the object, the property setting is (bitmap) or the path and file name of the graphic. If you delete (bitmap) or the path and file name of the graphic from the property setting, the picture is deleted from the object and the property setting is again (none)."

    How about setting the Picture property to "(none)" as the string? Just a complete shot in the dark.

    I cannot check it quickly at present.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File System Object - folder in use (2000/XP)

    Trying to set the Picture property to "(none)" or a variation thereof leads to an error message "Microsoft Access can't open the file (none)".

  15. #15
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File System Object - folder in use (2000/XP)

    Just for completeness I have tried:

    vbNullstring, "", Null, (none) and "(none)"

    Doesn't work. I am now happily hiding the control.

    Thanks for all the suggestions.

    ps have subsequently noticed similar behaviour when using OnCurrent in a form and have opted to showing/hiding the image control

Posting Permissions

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