Last Accessed?

satty

Board Regular
Joined
Jan 12, 2003
Messages
68
hello people,

im creating a form in MS Access 2000, and i have a login form on which i want to show when the database was last accessed.

doesn any1 know how to do this? i am aware of formulas like =NOW() which i can place in an unbound box, but i cant find anything about last accessed or something similar?

any help will be appreciated!

Thanx Guys
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Well, I've never tried but have thought about it and *knew* I'd seen something similar. If you're talking about the mdb file itself, you can use the filesystemobject to look at various properties of any file.

Make sure the Microsoft Scripting Runtime has been added to your references first.

Try this:

Code:
Function rAppObject()
Dim fsoSysObj As FileSystemObject
Dim fdrFolder As Folder
Dim filFile As File
Dim strPath As String

strPath = path_to_file_in_double_quotes

  Set fsoSysObj = New FileSystemObject
  Set fdrFolder = fsoSysObj.GetFolder(strPath)

  For Each filFile In fdrFolder.Files
      Debug.Print filFile.DateLastAccessed & " " & filFile.Name
  Next

End Function
 
Upvote 0
hey peeps

is there any simpler ways of doing this? im kind of very, VERY new to access and im not sure how to exactly carryout the above procedure.


and what is Microsoft Scripting Runtime. nad how do i add it to my reference first?

anyways anytihng will do?
 
Upvote 0
To add the Microsoft Scripting Runtime goto modules and open or create a new module.
then Tools>Reerences.... and scroll down the list until you fin one called "Microsoft Scripting Runtime" check this one and click OK.

I am not sure if the code above will work or not and cannot test it at the moment but I suspect it will give the last accesed date as when you just opend the file!

Another method may be to have your form save a Date/Time to a table when it closes and load that when it opens again.

HTH

Peter
 
Upvote 0
I found this within the Access VBA help.

But, as Bat said, yes it does just give you the current time and the far simpler solution is to just record a time/date stamp when you close the database, then you could use your Now() function.

Code:
Sub test()

Call ShowFileAccessInfo("c:\temp1.mdb") 'use yourfile name

End Sub

Sub ShowFileAccessInfo(filespec)
    Dim fs, d, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    s = UCase(f.Path) & vbCrLf
    s = s & "Created: " & f.DateCreated & vbCrLf
    s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
    s = s & "Last Modified: " & f.DateLastModified
    MsgBox s, 0, "File Access Info"
End Sub
 
Upvote 0
hey,

i bet u think what a dope. ehehhe, but im very new to this and am kind wanting to do things im not yet very capable of doing,

i was kind of hoping somebody will tell me how i can make it so that the form will open the last accessed (in this case closed) date, if i do use 'Bats' solution of =NOW()

Another method may be to have your form save a Date/Time to a table when it closes and load that when it opens again. Bat17

Thanx
 
Upvote 0
Create a table called tblLastUsed and in it create a field called LastUsed, set this field to a date field and save. add a date in the table, any date will do as the code will update it
in the On Open event of your form add the following code
Code:
Private Sub Form_Open(Cancel As Integer)
Me.txtLastUsed = DMax("[LastUsed]", "tblLastUsed")
End Sub
In the On Close event add the following code
Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
CurrentDb.Execute "UPDATE tblLastUsed SET tblLastUsed.LastUsed = Now();"
DoCmd.SetWarnings True
End Sub

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,564
Messages
6,160,513
Members
451,655
Latest member
rugubara

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top