Avatar of Hiken
Hiken
Flag for United States of America asked on

Access module problem killing files

What I'm trying to do is delete all files in a folder.  This code works except it locks up on a file called thumb.db.  Everything else deletes.  I don't see thumbs.db in the folder any ideas on how to fix?

Dim aflle As File
Dim afolder As Folder

Set afolder = fs.GetFolder(DLookup("CdfExportLocation", "tSetDefaults"))
       
   For Each afile In afolder.Files
     
        If IsNull(afolder) Then
   
   Else
   
        Kill (aFile)

End If
  Next
Microsoft Access

Avatar of undefined
Last Comment
ErezMor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ErezMor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rey Obrero (Capricorn1)

here is a dirty fix


On error resume next    'Add this line

Dim aflle As File
Dim afolder As Folder

Set afolder = fs.GetFolder(DLookup("CdfExportLocation", "tSetDefaults"))
       
   For Each afile In afolder.Files
     
        If IsNull(afolder) Then
   
   Else
   
        Kill (aFile)

End If
  Next
Hiken

ASKER
Thanks  that got it
ErezMor

cheers mate!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy