Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.SQL Question

Status
Not open for further replies.

Pilly170

IS-IT--Management
Aug 28, 2003
36
US
Hi,
I have this code that gets the files last modified date, all i want it to do is instert this into a field in a table.

I think the error is quite straight forward but cant see where ive gone wrong, just need antoher set of eyes i think.

I wanted to use update but i got a bit confused. any help will be grateful.


Function ShowFileInfo(filespec)
Dim fso, f
Dim strSQL As String

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
'ShowFileInfo = f.DateCreated
ShowFileInfo = f.DateLastModified

strSQL = "INSERT INTO File_Updated (Date_Time) VALUES ('ShowFileInfo')"


DoCmd.SetWarnings warningsoff
DoCmd.RunSQL strSQL
DoCmd.SetWarnings warningson

End Function
 
You need to build the date into the SQL:
Code:
strSQL = "INSERT INTO File_Updated (Date_Time) VALUES (#" & format(showFileInfo,"mm/dd/yyyy") & "#)"

When using dates and date fields directly in SQL, you need to enclose the date value in #s and make sure it is in US date format.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Fantastic, now if i wanted to add the time in as well??

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top