Results 1 to 2 of 2
  1. #1
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72

    file list code problem

    Hello, all. The code below worked fine until Wednesday. I know that sounds ridiculous as I write it. This code views a folder, and creates a table of file names and file dates that are the contents of the folder. The failure is in the line with the ***************** to the right (which are not there in the real code). It just hangs up, and stops entering dates.

    Any thoughts would be appreciated.


    Sub GetFiles(strPath As String)
    Dim rs As Recordset
    Dim strFile As String, strDate As Date

    'clear out existing data
    CurrentDb.Execute "Delete * From DispToRevTbl", dbFailOnError

    'open a recordset
    Set rs = CurrentDb.OpenRecordset("DispToRevTbl", dbOpenDynaset)

    'get the first filename


    strFile = Dir(strPath, vbNormal)
    'Loop through the balance of files
    Do
    'check to see if you have a filename
    If strFile = "" Then
    GoTo ExitHere
    End If
    strDate = FileDateTime(strPath & strFile)
    rs.AddNew
    'to save the full path using strPath & strFile
    'save only the filename
    rs!FileName = strFile
    rs!FileDate = strDate *************************************
    rs.Update

    'try for next filename
    strFile = Dir()
    Loop

    ExitHere:
    Set rs = Nothing
    'MsgBox ("Directory list is complete.")
    End Sub

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    After the following line
    strDate = FileDateTime(strPath & strFile)

    Add a debug.print
    Debug.Print strDate

    Make sure you have a value for strDate. If you do not like Debug.Print, you can use the Debugger and set a Breakpoint, then step through your code.

    What is the error saying when it halts execution?

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

Similar Threads

  1. Importing file directly from a Sharepoint file (not list)
    By jstoler in forum Import/Export Data
    Replies: 1
    Last Post: 06-28-2013, 01:44 PM
  2. Code for using a list box for criteria in a form
    By tomnsd in forum Programming
    Replies: 7
    Last Post: 01-23-2013, 10:52 PM
  3. Opening a file (PDF) from a subform (list) within a form
    By voodoo_ca in forum Database Design
    Replies: 31
    Last Post: 11-21-2012, 01:02 PM
  4. Import file list
    By pittpa1958 in forum Import/Export Data
    Replies: 4
    Last Post: 07-07-2011, 04:57 AM
  5. Value List with opening a file.
    By seaper in forum Forms
    Replies: 0
    Last Post: 10-21-2009, 01:32 PM

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