I have a button which executes some vba code which lists files and their date-created. I'm stumped on the sql insert with the datetime format insertion. The error returns a code 128 upon db.execute. Any ideas?
Do While Len(strFile) > 0
'Debug.Print strFolder & strFile
sSQL = "INSERT INTO tblVideos ( FileName , FileDate) VALUES ('" & strFile & "'," & Format(StrToDate(dateCreated(strFolder & strFile)), "\#yyyy-mm-dd hh:nn:ss\#") & ")"
Debug.Print sSQL
db.Execute sSQL, dbFailOnError
strFile = Dir()
Loop
end sub
Public Function StrToDate(strIn As String) As Variant
Dim var As Variant
Dim yr As Variant
If Len(strIn & "") Then
'StrToDate = CDate(Mid$(strIn, 3, 4) & "/" & Left$(strIn, 2) & "/" & Right$(strIn, 4))
var = Split(strIn, "/")
yr = Split(var(2), " ")
StrToDate = var(0) & "/" & var(1) & "/" & yr(0) & " " & yr(1)
Else
StrToDate = Null
End If
End Function