Thanks,
Denise
The FileDateTime function should get you that information.
Here's some code I use to choose a directory and place it into a textbox:
'---begin Code behind form---
Private Sub cmdGetPath_Click()
'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = "This is the title"
With tBrowseInfo
.hWndOwner = Me.hwnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
If Right(sBuffer, 1) <> "\" Then sBuffer = sBuffer & "\"
txtSaveFileDirectory.Value = sBuffer
End If
End Sub
'----end Code behind form----
'---begin Module code---
'----Code from http://support.microsoft.com/kb/179497
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const BIF_DONTGOBELOWDOMAIN = 2
Public Const MAX_PATH = 260
Public Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Public Declare Function SHBrowseForFolder Lib "shell32" _
(lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" _
(ByVal pidList As Long, _
ByVal lpBuffer As String) As Long
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal _
lpString2 As String) As Long
'----end Module code----
Once you have the directory you can use the Dir() function to get the
names of all the files in the directory. After that, you have what you
need to run the FileDateTime function on all the files in the directory.
James A. Fortune
MPAP...@FortuneJames.com
Thanks,
To get to the code behind a form, single click on the form's name and
click 'Design.' Next select View...Code. You only need to put the code
in once, but don't paste the code in yet. Unlike module code, Access
sometimes doesn't attach pasted form code to the buttons correctly. You
need to go back to the form design and create a command button called
'cmdGetPath' and a textbox called 'txtSaveFileDirectory' first. Double
click cmdGetPath, select the 'Event' tab, click in the white rectangle
to the right of the 'On Click' event, then click on the three dots to
the far right. In the box that says 'Choose Builder,' double click
'Code Builder' or select 'Code Builder' and click 'OK.' That is where
to paste the code behind form.
I'll look around to see if I have an example of pulling all the files
from a directory for you to look at. The FileDateTime can be called in
a loop by exploiting the behavior of the Dir() function when called
multiple times.
James A. Fortune
MPAP...@FortuneJames.com
> I'll look around to see if I have an example of pulling all the files
> from a directory for you to look at. The FileDateTime can be called in
> a loop by exploiting the behavior of the Dir() function when called
> multiple times.
I placed a sample A97 database at:
http://personalwebs.oakland.edu/~fortune/FileTimes.zip
It worked on a directory containing over 12,000 files.
James A. Fortune
MPAP...@FortuneJames.com
In the Form_Open event, put the name of the hard-coded directory into
the textbox. Afterwards, in the same event, copy the code after the
directory is selected from cmdGetPath. Then delete cmdGetpath's code
and the command button. You can skip adding the information to the
listbox. The table should refresh each time the form is opened. Post
back if you need help with any of that.
James A. Fortune
MPAP...@FortuneJames.com
I placed a hardcoded version at:
http://personalwebs.oakland.edu/~fortune/FileTimesHardCoded.zip
After converting it, hold down the shift key while opening it and change
the first line of Form_Load,
txtSaveFileDirectory.Value = "T:\Databases\"
to
txtSaveFileDirectory.Value = "YourNetworkDriveLetter:\YourNetworkPath\"
Once the database/form is opened, tblFiles will contain the filenames in
a field called FileName and the file creation/modification dates
(including time) in a field called FileDate.
James A. Fortune
MPAP...@FortuneJames.com
Is there something else I need to change?
As a matter of fact, there is. In addition to the line
'txtSaveFileDirectory = "T:\Databases\"' add another line after that one
that says:
sBuffer = txtSaveFileDirectory.Value
sBuffer was a string that got filled by the treeview and needs to be set
to the hard-coded value. I'll try to update the file in the link today
also. It should also work with UNC paths. Thanks for catching that.
James A. Fortune
MPAP...@FortuneJames.com