I have written a module that will take the date a file is created and put the value into a variable. The file in question was created on 1/13/2014. Once I determine the date the file is created I update a table. The issue happens when I update the table. The value that goes into the table is 12/30/1899. I was hoping I could get some assistance in resolving this issue. When I step through the code
At this point dCreateDate = oFS.GetFile(strFilename).DateCreated I get 1/13/2014 4:45:57 PM
At this point dCreateDate = Format(dCreateDate, "dd/mm/yyyy") 1/13/2014
At this point strSQL = "UPDATE zzz_CalcAR SET zzz_CalcAR.AgeDate = " & dCreateDate I get 1/13/2014
But then I look in the table and I see 12/30/1899
Tom
At this point dCreateDate = oFS.GetFile(strFilename).DateCreated I get 1/13/2014 4:45:57 PM
At this point dCreateDate = Format(dCreateDate, "dd/mm/yyyy") 1/13/2014
At this point strSQL = "UPDATE zzz_CalcAR SET zzz_CalcAR.AgeDate = " & dCreateDate I get 1/13/2014
But then I look in the table and I see 12/30/1899
Tom
Code:
Public Function xlReadDateCreated(dCreateDate As Date)
'Call xlReadDateCreated(dCreateDate)
Dim oFS As Object
Dim strFilename As String
Dim strFileLoc As String
Dim strSQL As String
Dim rst As DAO.Recordset
Dim i As Integer
Dim strCSFile As String
'Put your filename here
strFileLoc = "\\server\E\Balout\"
strSQL = "SELECT dbo_rpt_FYInfo.uci, dbo_rpt_FYInfo.rptpddiff, dbo_rpt_FYInfo.csfile " & _
"FROM dbo_rpt_FYInfo " & _
"WHERE dbo_rpt_FYInfo.uci='UCM' AND dbo_rpt_FYInfo.rptpddiff=1;"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rst.EOF Then ' Make sure not empty set
With rst
.MoveLast
.MoveFirst
End With
For i = 1 To rst.RecordCount
strCSFile = (rst![csfile])
Next
strFilename = strFileLoc & strCSFile
'This creates an instance of the MS Scripting Runtime FileSystemObject class
Set oFS = CreateObject("Scripting.FileSystemObject")
dCreateDate = oFS.GetFile(strFilename).DateCreated
dCreateDate = Format(dCreateDate, "dd/mm/yyyy")
Set oFS = Nothing
End If
-----Function-------
Public Function ProcessQueries()
Dim strSQL As String
Dim rst As DAO.Recordset
Dim i As Integer
Dim dCreateDate As Date
With DoCmd
.SetWarnings False
.OpenQuery "000_ClearAgingReport"
.OpenQuery "000_ClearARCalc"
.OpenQuery "000_ClearImport"
.OpenQuery "000_ClearPatSummaryTotals"
.OpenQuery "000_Clear_PatSummary"
.OpenQuery "010_PostAR"
.OpenQuery "011_SetInsName"
.OpenQuery "012_SetPatientData"
Call xlReadDateCreated(dCreateDate)
strSQL = "UPDATE zzz_CalcAR SET zzz_CalcAR.AgeDate = " & dCreateDate
CurrentDb.Execute (strSQL)
'.OpenQuery "020_UpdateAgingDate"
.OpenQuery "030_CalcAgingDays"
.OpenQuery "040_SetBucket"
.OpenQuery "050_GetPatSummaryTotals"
.OpenQuery "060_MakePatSummaryEntries"
.OpenQuery "070_PostAgingReportData"
.OpenQuery "080_UpdateReportBucketEntries"
.SetWarnings True
End With
End Function