Results 1 to 3 of 3

Thread: Getting date created

  1. #1

    Thread Starter
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674

    Getting date created

    I have been trying to use the code below to get the creation date from a list of files and by matching the name of the file to a record in an access database putting the creation date for the match.

    It is not working. I am wondering if instead of using a vb form to do this, if it would be easier/better to do this through code in access.

    Any Help?

    PLEASE!?!

    Thanks,

    JO


    Current code:

    Code:
    Dim db As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim filesys As FileSystemObject
    Dim fol As Folder
    Dim fil As File
    Dim ssql As String
    
    Set db = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set filesys = New FileSystemObject
    
    With db
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=" & App.Path & "\db1.mdb"
    .Open
    End With
    
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenDynamic
    rs.ActiveConnection = db
    
    ssql = "Select * From WOINFO"
    
    rs.Open ssql
    
    Set fol = filesys.GetFolder("d:\DCtest\")
    
    For Each fil In fol.Files
    rs.MoveFirst
    Do Until rs.EOF
    'If fil.Name = rs("WONumber") Then
    'rs("ScanDate") = fil.DateCreated
    'rs.Update
    'End If
    List1.AddItem (fil.DateCreated)
    rs.MoveNext
    Loop
    Next fil
    
    
    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing
    Set filesys = Nothing
    Set fil = Nothing
    Set fol = Nothing
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  2. #2
    Lively Member Surgeon's Avatar
    Join Date
    Oct 2000
    Posts
    121

    Thumbs up

    You might try this instead :
    Code:
    Dim db As ADODB.Connection
    Dim filesys As FileSystemObject
    Dim fol As Folder
    Dim fil As File
    Dim ssql As String
    
    Set db = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set filesys = New FileSystemObject
    
    With db
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=" & App.Path & "\db1.mdb"
    .Open
    End With
    
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenDynamic
    rs.ActiveConnection = db
    
    'you get each file and search its name within the database
    ' if you find it, then you update the WONumber field's value.
    Set fol = filesys.GetFolder("d:\DCtest\")
    For Each fil In fol.Files
        db.Execute "UPDATE WOINFO SET ScanDate = '" & fil.DateCreated & "' Where (WONumber = """ & fil.Name & """);"
    Next fil
    
    db.Close
    Set db = Nothing
    Set filesys = Nothing
    Set fil = Nothing
    Set fol = Nothing
    But this would only work if your ScanDate field is a String Type field. If it's datatype is Date, then it won't work. If this is the case, plz give me a shout and I'll give you the right directions.

    Regards,
    Surgeon

  3. #3

    Thread Starter
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    Thank you!!

    I got sent out of town unexpectedly so I won't be able to try it until Tuesday. I certainly do appreciate it and I will let you know!!

    Thanks again,

    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

Posting Permissions

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



Click Here to Expand Forum to Full Width