How to fill the "LastUpdate" field automatically?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sheelanv
    New Member
    • Dec 2009
    • 2

    #1

    How to fill the "LastUpdate" field automatically?

    Hi,

    I have two fields in my Table - "ID" and "LastUpdate " and i want the "LastUpdate " field to be updated with the current date and time whenever i make any changes to the field "ID" or add a new ID. Can someone kindly support me with this?
    I am extremely new to MS Access and have a poor VB knowledge hence, would be great if someone can give me a detailed process...

    Sheela
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    Assuming that the records are added and updated in a Form then
    perhaps something like this
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        [LastUpdate]=Now()
    End Sub
    ??


    MTB

    Comment

    • sheelanv
      New Member
      • Dec 2009
      • 2

      #3
      Hi Mike,

      thanks for the quick reply.. however I update the ID directly into the table and not by using forms.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Then you're out of luck! Data should never be entered directly into a table!

        Go to Forms in the database window, click on Create form by using Wizard and follow the Wizard's instruction to create a form based on your table. Then, from Form Design View, go to the View Menu and click on Code. Paste in Mike's code and you should be set.

        Welcome to Bytes!

        Linq ;0)>

        Comment

        Working...