S D
accessd667 at yahoo.com
Wed Feb 11 02:01:25 CST 2004
Hi group,
I'm using FileSystemObject to delete a MDB file.
After that I'm creating a new MDB.
Then i'm using the .DateCreated method to get the the info about when the file was created. I checked this in the help: "Returns the date and time that the specified file or folder was created. Read-only."
However the time it returns is the date\time combination of when I created the DB for the first time.
EG: I'm starting the application at 8:00. I then show on screen the date\time the temp (analyses) db was created, let's say that it was created on 10 feb 2004 16:34:56. I then decide to create a new temp db. I press the button and it deletes the file, creates a new one and adds tables to it. Then I show the user the .DateCreated wich shows 8:00.
When I stay in the program and do the above at 8:15 the .DateCreated method returns again 8:00!!! When I look in Explorer the DateCreated column shows 8:00 and the DateModified shows 8:15?!!? QUA PASA. WHY is the date created 8:00? I've checked in Explorer that the file is gone after the deletefile statement.
Any ideas?
Sander
Here's part of my code:
FORM LOAD:
'Create temporary database
blnCreateTables = CreateTempDatabase(LOCATION_TEMP_DB, TEMP_DB_NAME)
If blnCreateTables Then
'Create tables
Call CreateTables(LOCATION_TEMP_DB, TEMP_DB_NAME)
...
...
Function CreateTempDatabase(strPath As String, strDbName As String) As Boolean
On Error GoTo Err_CreateTempDatabase
Dim dbDestination As DAO.Database
Dim blnDbExists As Boolean
Dim blnCreateDB As Boolean
'Check if file exists
blnDbExists = FileExists(strPath & strDbName)
If blnDbExists Then
Select Case MsgBox("Temporary database EXISTS. Do you want to DELETE it and create a new one?", vbYesNo + vbInformation + vbDefaultButton1, "Temporary database exists")
Case vbYes
'Delete file!
If DeleteFile(strPath & strDbName) Then
blnCreateDB = True
....
....
'Create TEMPDB
If blnCreateDB Then
Set dbDestination = Workspaces(0).CreateDatabase(strPath & strDbName, DB_LANG_GENERAL)
End If
'Set return value
CreateTempDatabase = blnCreateDB
'errorhandling
END FUNCTION
Public Function DeleteFile(strFileName As String) As Boolean
On Error GoTo Err_DeleteFile
Dim fso As FileSystemObject
Dim file As String
Dim strFileNameLDB As String
file = strFileName ' change to match the file w/Path
Set fso = New FileSystemObject
'Set fso = CreateObject("Scripting.FileSystemObject")
strFileNameLDB = "C:\Program Files\Switchdatabase\Temp_Db_Switch.ldb"
If fso.FileExists(strFileName) Then
fso.DeleteFile strFileName, True
If fso.FileExists(strFileNameLDB) Then
fso.DeleteFile strFileNameLDB, True
End If
'return value
DeleteFile = True
Else
'return value
DeleteFile = False
End If
Exit_DeleteFile:
Exit Function
Err_DeleteFile:
MsgBox Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
"Location: DeleteFile()"
Resume Exit_DeleteFile
End Function
Function CheckNewFile(strFile As String) As String
On Error GoTo Err_CheckNewFile
Dim objFileSys As FileSystemObject
Dim objFile As file
Dim strFileName As String
Dim strNewDateCreated As String
Set objFileSys = New FileSystemObject
strFileName = strFile
If objFileSys.FileExists(strFileName) Then
Set objFile = objFileSys.GetFile(strFileName)
'Get file created value
With objFile
strNewDateCreated = .DateCreated
End With
Else
'File does NOT exist!
strNewDateCreated = vbNullString
GoTo Exit_CheckNewFile
End If
'Set returnvalue
CheckNewFile = strNewDateCreated
....errrorhandling
End Function
---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online