General discussion

  • Creator
    Topic
  • #2101505

    Access Time Stamp

    Locked

    by rsploss ·

    How do I date/time stamp the creation of a new record, and the updating of a record?

All Comments

  • Author
    Replies
    • #3635771

      Access Time Stamp

      by robert_a_mocarski ·

      In reply to Access Time Stamp

      add a field to the table with a date/time data type. Create a form to control adds/edits of the record. Add the timestamp field that you added to the table. It can be visible or hidden. On the properties of the form, add VBA code to the before update event.

      The code is
      Dim MyDate
      MyDate = Now
      time = MyDate

      In that code, the field name from the table is called “time”. Edit to match your field name.

      Make sure you don’t add the code to the after update event. That will cause Access to save the record, change the timestamp field, and then update the record again because it detected the change. An odd loop, but it does happen.

      • #3618606

        Access Time Stamp

        by rsploss ·

        In reply to Access Time Stamp

        I’m sorry, Robert, that I couldn’t get your suggestion to work for me.

    • #3633824

      Access Time Stamp

      by seagull data services ·

      In reply to Access Time Stamp

      There are a couple of ways to do this but you need to create a date/time field in your table. Call it DateCreated:
      Using a form –
      create a hidden text box on the form (call it txtDateCreated) and link it to the DateCreated field.
      In the event that saves the record, add the line
      me.txtDateCreated=now
      This will add the date and time in the appropriate place

      Using Code –
      where rs is the recordset you’re saving to, add this code.

      with rs
      .addnew
      ‘update other fields from the form then

      !DateCreated=Now
      .update
      end with

      Hope this helps
      John

      • #3618607

        Access Time Stamp

        by rsploss ·

        In reply to Access Time Stamp

        Thank you, John. Your suggestion is simple and it works. Also, I appreciate seeing the same thing done in code.

    • #3618605

      Access Time Stamp

      by rsploss ·

      In reply to Access Time Stamp

      This question was closed by the author

Viewing 2 reply threads