p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: date access property


Message #1 by "Johnny" <gordon@i...> on Mon, 24 Jun 2002 23:17:24 +0100
Using Access 2000, is there any way I can obtain the date when a table was
last used i.e. when a record was added or changed.

There is already a table property called Last Updated, however this relates
to the date the design of the table was last updated.






Message #2 by Patrick_Slesicki@d... on Mon, 24 Jun 2002 15:29:31 -0700
Hi Johnny ,

First you'll need to add fields to your tables. In this code example I've
fields for when a record is added as well as when it's edited. Hope it
helps.


Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.NewRecord Then
        Me.txtAddedBy = CurrentUser
        Me.txtDateAdded = Now
    End If

    If Me.Dirty Then
        Me.txtEditedBy = CurrentUser
        Me.txtDateEdited = Now
    End If

    Dim strMsg As String
    strMsg = "Data has changed."
    strMsg = strMsg & "@Do you wish to save the changes?"
    strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
    If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
        'do nothing
    Else
        DoCmd.RunCommand acCmdUndo
    End If

End Sub



                                                                                                                   
                          "Johnny"                                                                                 
                    <gordon@i...       To:     "Access" <access@p...>                                    
                                 >       cc:                                                                       
                                         Subject:     [access] date access property                                
                    06/24/02 03:17                                                                                 
                                PM                                                                                 
                    Please respond                                                                                 
                       to "Access"                                                                                 
                                                                                                                   
                                                                                                                   




Using Access 2000, is there any way I can obtain the date when a table was
last used i.e. when a record was added or changed.

There is already a table property called Last Updated, however this relates
to the date the design of the table was last updated.











  Return to Index