Unload Me? API SetFileTime: Obtain & Change File's Create, Access & Modify Date By Randy Birch

R

rebelscum0000

Dear All,

I am triying to understand how SetFileTime: Obtain and Change a File's
Created, Accessed and Modified Dates By Randy Birch
http://vbnet.mvps.org/index.html?code/fileapi/filedatetime.htm
Works.

I created the form, called "Form2 SetFileTime and "
I followed all the instruction to test it

But Each time I click on "End" [Command1_Click()]

I get "Run-time error '361'
Can't load or unload this object

Private Sub Command1_Click()

Unload Me

End Sub

IF I Change this line for

Private Sub Command1_Click()

Unload Form2SetFileTime

End Sub

I get the error "Compile error Variable not defined"

Finally the Unload Statement is not clear for me when do you use
Unload
Or Load and What for?

Any help is more than welcome

Thanks in advance
Regards,
Antonio Macias
 
D

Douglas J. Steele

Randy's site is aimed at VB programmers. There are significant differences
between forms in VB and in Access, so sometimes the code doesn't port
directly.

In VB, you unload a form. In Access, you close it.

Try using

DoCmd.Close
 
R

rebelscum0000

Dear Doug Steele,

In this post

http://groups.google.com/group/micr...ile+properties+&rnum=1&hl=en#c25b739bcd292580

Q: I need to compare the created dates of 2 files to
determine which one is older, then replace the first file
if it is older then the second file.

I need the same!

You wrote:
You can use the GetFileTime API (plus some others). Randy Birch has
sample
code at http://vbnet.mvps.org/code/fileapi/filedatetime.htm, which
should
port into Access without any problem.

I am using GetFileTime API by Randy Birch I had to modify some lines:

Private Sub Command1_Click()

DoCmd.Close 'Modified Replace for Unload Me

End Sub

Private Sub Command2_Click()

'----- debug only --------------------------- 'Modified
'show the system time info
tmp = "Date Created:" & " " & GetFileDateString(FT_CREATE) & vbCrLf
'Modified vbTab
tmp = tmp & "Last Modified:" & " " & GetFileDateString(FT_WRITE) &
vbCrLf 'Modified (3) vbTab, Order, vbCrLf
tmp = tmp & "Last Access:" & " " & GetFileDateString(FT_ACCESS)
'Modified (2) Order, vbCrLf
Text2.SetFocus 'Modified Add it
Text2.Text = tmp
'--------------------------------------------

'----- debug only ---------------------------
'show the system time info
tmp = ""
tmp = "Day:" & " " & SYS_TIME.wDay & vbCrLf 'Modified vbTab
tmp = tmp & "Month:" & " " & SYS_TIME.wMonth & vbCrLf 'Modified vbTab
tmp = tmp & "Year:" & " " & SYS_TIME.wYear & vbCrLf 'Modified vbTab
tmp = tmp & "String:" & " " & GetSystemDateString(SYS_TIME) 'Modified
vbTab
Text3.SetFocus 'Modified Add it
Text3.Text = tmp
'--------------------------------------------

'set the created, accessed and modified dates all
'to the new dates. A null (0&) could be passed as
'any of the NEW_TIME parameters to leave that date unchanged.
'Call SetFileTime(hFile, NEW_TIME, NEW_TIME, NEW_TIME) 'Modified REM
TO AVOID CHANGES

're-read the updated FILETIME info for the created,
'accessed and last write info
'Call GetFileTime(hFile, FT_CREATE, FT_ACCESS, FT_WRITE) 'Modified REM
TO AVOID CHANGES


'----- debug only ---------------------------
'show the system time info
tmp = "New Date Created:" & vbTab & GetFileDateString(FT_CREATE) &
vbCrLf
tmp = tmp & "New Last Modified:" & vbTab & GetFileDateString(FT_WRITE)
& vbCrLf 'Modifed Order
tmp = tmp & "New Last Access:" & vbTab & GetFileDateString(FT_ACCESS)
& vbCrLf
Text4.SetFocus 'Modified Add it
Text4.Text = tmp
'--------------------------------------------
End Sub

I am sure the modifications and additions to the original code I did.
do not affect the results
Or I am wrong?

The problem is with some files, I do not know which ones, or which
kind of files, I just open them in a Random way
The result I get is ONE DAY AFTER FROM their original Properties
Fille; I do know why this happens, or what is wrong with the code

I have several examples this File Returns One Day After

Path:
C:\Documents and Settings\Antonio Macias\Desktop\ERROR.xls
File:
ERROR.xls
LeftClick on File (ERROR.xls) Click on Properties
General Tab
ERROR.xls s Properties

Created : Thursday, November 02, 2006, 6:08:10 PM
Modified: Thursday, November 02, 2006, 6:08:10 PM
Acccesed: Today, April 27, 2007, 4:15:15 PM

Private Sub Command3_Click()
Same as above, no problem here, NO HOUR STILL

Private Sub Command2_Click()
Original File Date Info:
Date Created: Friday November 3, 2006
Last Modified: Friday November 3, 2006
Last Access: Friday April 27, 2007

System Date:
Day: 27
Month: 4
Year: 2007
String: Friday April 27, 2007

New File Date Info:
New Date Created: Friday November 3, 2006
New Last Modified: Friday November 3, 2006
New Last Access: Friday April 27, 2007

In this example, I thought I had no problem until I read the Last
Access
IF Today is April 27, 2007 why when I click on Command2_Click() I get
Last Access: Saturday April 28, 2007
Hmmm, Am I living in a expanded universe? LOL
Please note: I remember that in my first check, the result of Last
Access: in New Last Access: was:
Today, April 27, 2007
but I am not complete sure.

Path:
C:\Fotos AMC\Seleccion Fotos.xls
File:
Seleccion Fotos.xls
LeftClick on File (Seleccion Fotos.xls) Click on Properties
General Tab
Seleccion Fotos.xls Properties

Created : Wednesday, April 25, 2007, 1:54:11 AM
Modified: Wednesday, April 25, 2007, 11:44:03 AM
Acccesed: Today, April 27, 2007, 1:36:55 PM

Private Sub Command3_Click()
Same as above, no problem here

Private Sub Command2_Click()
Original File Date Info:
Date Created: Wednesday April 25, 2007
Last Modified: Wednesday April 25, 2007
Last Access: Saturday April 28, 2007

System Date:
Day: 27
Month: 4
Year: 2007
String: Friday April 27, 2007

New File Date Info:
New Date Created: Wednesday April 25, 2007
New Last Modified: Wednesday April 25, 2007
New Last Access: Saturday April 28, 2007

Last example:

Path:
C:\ C:\DVD Basic_8116\Microsoft\Utilities\Powertoys XP\RAW Image
Thumbnailer & Viewer\V. 1.0, B 50\EN\RAWViewerSetup.exe
File:
RAWViewerSetup.exe
LeftClick on File (RAWViewerSetup.exe) Click on Properties
General Tab
Seleccion Fotos.xls Properties

Created : Sunday, November 05, 2006, 7:02:11 PM
Modified: Friday, March 03, 2006, 11:44:42 PM
Acccesed: Today, April 29, 2007, 2:29:08 PM

Private Sub Command3_Click()
Same as above, no problem here

Private Sub Command2_Click()
Original File Date Info:
Date Created: Monday November 6, 2006
Last Modified: Saturday March 4, 2006
Last Access: Sunday April 29, 200 7

System Date:
Day: 29
Month: 4
Year: 2007
String: Sunday April 29, 2007

New File Date Info:
New Date Created: Monday November 6, 2006
New Last Modified: Saturday March 4, 2006
New Last Access: Sunday April 29, 2007

What could be the problem? Please help me!

Thanks in advance
Regards,
Antonio Macias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top