Add user and time stamp only to new records?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrisdavies
    New Member
    • Jul 2007
    • 11

    Add user and time stamp only to new records?

    Hi Guys - I've got a SQL Server backend and access front end.

    I suspect this is pretty simple, but I want to add created by and when info to new records in my database, and modified by and when, when records are updated.

    My question is, how do I get add the created details to new records ONLY. So for eg. if record is new...... then do etc.

    Hope this makes sense.

    Thanks - Chris
  • chrisdavies
    New Member
    • Jul 2007
    • 11

    #2
    My short term solution is to check whether the created info fields are null. I would like something more robust though...

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      You have inadvertently posted your question in the Articles section rather than in the Forum section of our site, so I have moved it across to the Forum for you.

      Welcome to TheScripts!

      Linq ;0)>

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        [CODE=vb]Private Sub Form_Current()
        If Me.NewRecord Then
        ' Place your here code for new records only
        Else
        'Place code here for existing records only
        End If
        End Sub
        [/CODE] Linq ;0)>

        Comment

        • chrisdavies
          New Member
          • Jul 2007
          • 11

          #5
          Originally posted by missinglinq
          [CODE=vb]Private Sub Form_Current()
          If Me.NewRecord Then
          ' Place your code for new records here
          End If
          End Sub
          [/CODE] Linq ;0)>

          Brilliant!!!! Cheers for that.

          Chris

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            Glad we could help! I edited that a bit, by the way, in case there's something you only want to do for existing records! Note that anything in the Else clause will occur ever time you visit an existing record!

            Comment

            Working...