Results 1 to 3 of 3
  1. #1
    queuebug is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Working with Files

    I am upgrading my Access 2003 database to Access 2010. This code worked perfectly in 2003, but I keep getting an error in 2010. It might be that the reference isn't correct. Searching the net, I thought I might need to use "Microsoft Scripting Runtime", but it still doesn't work. It breaks at "Set fso = FileSystemObject". Here is my code. Any help would be appreciated!



    Code:
     
    Dim sDate As Date
    Dim sPath As String
    Dim fso As FileSystemObject
    Dim oFldr As Folder
    Dim oFile As File
    sDate = Now() - 60
    sPath = "\\Data\Custom\Archive\"
     
    Set fso = FileSystemObject
    Set oFldr = fso.GetFolder(sPath)
     
        If oFldr <> "" Then
     
            For Each oFile In oFldr.Files
     
                If DateSerial(Mid(oFile, 45, 2), Mid(oFile, 47, 2), Mid(oFile, 49, 2)) < sDate Then
     
                    oFile.Delete
     
                End If
     
            Next oFile
     
        End If
     
    DeleteOld_exit:
        Set oFile = Nothing
        Set oFldr = Nothing
        Set fso = Nothing
        Exit Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I got to work with these edits:

    ...
    Dim oFldr
    ...
    Set fso = CreateObject("Scripting.FileSystemObject")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    queuebug is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2
    That worked perfectly! Thanks June7!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. recovering *.RBF and .DAT* Files
    By frowsyone in forum Import/Export Data
    Replies: 3
    Last Post: 03-20-2014, 04:14 PM
  2. Files cannot update
    By ashmariane in forum Forms
    Replies: 10
    Last Post: 09-05-2011, 01:02 AM
  3. Attached Files
    By tcheck in forum Access
    Replies: 1
    Last Post: 08-11-2011, 09:46 PM
  4. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  5. Linking up two files
    By heidiffg in forum Access
    Replies: 0
    Last Post: 02-14-2011, 09:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums