Hi there
I run a piece of VBA code that builds a temp MDB file and at the end
compacts it into a new file, with a different name; the same temp file is again compacted into another file, with a slightly different name
The below code builds the target filename into DBfilename, check whether already exists, in case deletes it, compacts the temp into the target using
a different folder and at the end moves the target in it's proper location
The above is repeated with another target name
Dim DBfilename As String
DBfilename = NN & Ty & CO & MA & "DATI_REP.Mdb"
' 1
If Dir_Exist(Me.APP_PATH & DBfilename) <> "" Then
Kill Me.APP_PATH & DBfilename
End If
DBEngine.CompactDatabase Me.APP_PATH & "DATI_REP.MDB", Me.APP_PATH
& "temp\" & DBfilename
Name Me.APP_PATH & "temp\" & DBfilename As Me.APP_PATH & DBfilename
' 2
DBfilename = NN & Ty & CO & MA & Format(Me.RIFYEAR, "0000") & Format(Me.RIFMONTH, "00") & "DATI_REP.Mdb"
If Dir_Exist(Me.APP_PATH & DBfilename) <> "" Then
Kill Me.APP_PATH & DBfilename
End If
DBEngine.CompactDatabase Me.APP_PATH & "DATI_REP.MDB", Me.APP_PATH
& "temp\" & DBfilename
Name Me.APP_PATH & "temp\" & DBfilename As Me.APP_PATH & DBfilename
Now, where is the problem? In a different subsequent procedure I show the list of available MDB files, with the CREATION DATE aside, using the following code
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oF = oFSO.GetFile(Me.APP_PATH + MyName)
CreationDate = oF.DateCreated
etc
What happens? the creation date of the a.m. newly built mdb files is the
same of the previously existing file, the one I have DELETED
The strange thing is that if I execute the code step-by-step (F8) checking the file/folders after every instruction, I can see exactly what I expect: files are deleted, built in temp, moved back, and the final creation date
is the date I want, now.
If I run the code with no stop or debug, files are deleted, built and moved properly, but the creation date of the new files is the same of the old deleted ones
https://i.imgur.com/QBITIrA.png
The picture shows the "green" files with correct creation date obtained running step-by-step
The "yellow" files are the result of the code execution with no debug (the related log is shown on the left)
Any help and suggestion is welcome.
Just a couple of ideas:
- the CreationDate = oF.DateCreated instruction is a mistake
- NTFS has a bug
Access version 2010, running on Windows 7
Thank you
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........
Hi there
I run a piece of VBA code that builds a temp MDB file and at the end
compacts it into a new file, with a different name; the same temp file is again compacted into another file, with a slightly different name
The below code builds the target filename into DBfilename, check whether already exists, in case deletes it, compacts the temp into the target using
a different folder and at the end moves the target in it's proper location
The above is repeated with another target name
Dim DBfilename As String
DBfilename = NN & Ty & CO & MA & "DATI_REP.Mdb"
' 1
If Dir_Exist(Me.APP_PATH & DBfilename) <> "" Then
Kill Me.APP_PATH & DBfilename
End If
DBEngine.CompactDatabase Me.APP_PATH & "DATI_REP.MDB", Me.APP_PATH
& "temp\" & DBfilename
Name Me.APP_PATH & "temp\" & DBfilename As Me.APP_PATH & DBfilename
' 2
DBfilename = NN & Ty & CO & MA & Format(Me.RIFYEAR, "0000") & Format(Me.RIFMONTH, "00") & "DATI_REP.Mdb"
If Dir_Exist(Me.APP_PATH & DBfilename) <> "" Then
Kill Me.APP_PATH & DBfilename
End If
DBEngine.CompactDatabase Me.APP_PATH & "DATI_REP.MDB", Me.APP_PATH
& "temp\" & DBfilename
Name Me.APP_PATH & "temp\" & DBfilename As Me.APP_PATH & DBfilename
Now, where is the problem? In a different subsequent procedure I show the list of available MDB files, with the CREATION DATE aside, using the following code
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oF = oFSO.GetFile(Me.APP_PATH + MyName)
CreationDate = oF.DateCreated
etc
What happens? the creation date of the a.m. newly built mdb files is the
same of the previously existing file, the one I have DELETED
The strange thing is that if I execute the code step-by-step (F8) checking the file/folders after every instruction, I can see exactly what I expect: files are deleted, built in temp, moved back, and the final creation date
is the date I want, now.
If I run the code with no stop or debug, files are deleted, built and moved properly, but the creation date of the new files is the same of the old deleted ones
https://i.imgur.com/QBITIrA.png
The picture shows the "green" files with correct creation date obtained running step-by-step
The "yellow" files are the result of the code execution with no debug (the related log is shown on the left)
Any help and suggestion is welcome.
Just a couple of ideas:
- the CreationDate = oF.DateCreated instruction is a mistake
- NTFS has a bug
Access version 2010, running on Windows 7
Thank you
How about:
CreationDate = DateTime(now)
I wonder if Filemanager isn't cacheing the old fileinfo for your
filename next time it looks in that folder. What happens if you open a command window and do a Dir.
Here's the code
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 61:39:38 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,534 |