How Do I Display A Full File Path And Creation Date?

YuvalH

New member
Local time
Today, 16:47
Joined
Jan 21, 2022
Messages
13
Hi,
I'm new to access but I have some experience, I'm having trouble finding a way to display a full file path and creation date.
Thx for the help.
צילום מסך 2022-01-21 213720.png
 
Why are you having trouble? Is this not data in record? If not, where should data come from?
 
paste the code below into a module:

Code:
Public Function UserPick1File(byval pvPath)
Dim strTable As String
Dim strFilePath As String
Dim sDialogMsg As String, sDecr As String, sExt As String
'const msoFileDialogFilePicker = 3
If IsMissing(pvPath) Then pvPath = "c:\"   ' getMyDocs()
'SetFileFilter pvFilter, sDecr, sExt, sDialogMsg
With Application.FileDialog(3)
.AllowMultiSelect = True
.Title = sDialogMsg ' "Locate a file to Import"
.ButtonName = sDialogMsg '"Import"
.Filters.Clear
'.Filters.Add sDecr, sExt
'.Filters.Add "Access Files", "*.accdb;*.mdb"
'.Filters.Add "Excel Files", "*.xlsx"
.Filters.Add "All Files", "*.*"
.InitialFileName = pvPath
    .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
        If .show = 0 Then
'There is a problem
Exit Function
        End If
    'Save the first file selected
UserPick1File = Trim(.SelectedItems(1))
End With
End Function

Public Function getModifiedDate(ByVal pvFile)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(pvFile)
getModifiedDate = f.DateLastModified

Set f = Nothing
Set fs = Nothing
End Function

Public Function getCreatedDate(ByVal pvFile)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(pvFile)
getCreatedDate = f.DateCreated

Set f = Nothing
Set fs = Nothing
End Function


then user can click a button on the form to select the file using:
FORM CODE:
Code:
sub btnPickFile_Click()
sStartFolder = "c:\temp\"
vFile = UserPick1File(sStartFolder)
if vFile <> "" then
   txtFile = vFile
   txtCreateDate = getCreatedDate(vFile)
endif
end sub
 
Be aware that if the file has been copied from somewhere - the created date is actually the date it was copied. Or you use the modified date which is probably pretty safe in the context of pictures taken with a digital camera and not subsequently modified

1642806773285.png

Otherwise somehow I managed to modify the above 16 years before creating it!

It may be you need the Date Taken value which I don't believe you can get from filesystem object. You might want to take a look at this link

 
Last edited:
Be aware that if the file has been copied from somewhere - the created date is actually the date it was copied.

View attachment 97705
Otherwise somehow I managed to modify the above 16 years before creating it!

It may be you need the Date Taken value which I don't believe you can get from filesystem object. You might want to take a look at this link

I have always wondered if they were going to ever fix that? :)
 
thing is it is about the file - and the file was created when it was copied.
1642809935332.png

the first file I copied - so new copy created
The second file is the same file but moved - so it wasn't created

changing the file name doesn't constitute a change
 

Users who are viewing this thread

Back
Top Bottom