Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    Unanswered: How do I create a timestamp?

    I'm using Access 2000.

    I have a column named DateModified. I want this column to save the current date/time the row is saved or updated.

    I know this should be easy, but I can't figure it out (I'd blame it on the NyQuil, but I doubt that's entirely to blame).

    Thanks!

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Define the column as a date/time datatype. In the default field put the function Now - this will insert the current date time when a record is inserted.

  3. #3
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    Thanks -- it worked!

    I put the Now() function in the Access column. I also added the function to the ASP form so it will restamp it each time the record is saved.

    Thanks a bunch!

    Mike

  4. #4
    Join Date
    Nov 2002
    Posts
    14

    Re: Thanks -- it worked!

    Originally posted by buzzter66
    I put the Now() function in the Access column. I also added the function to the ASP form so it will restamp it each time the record is saved.

    Thanks a bunch!

    Mike
    Do you want a date field for date the record was created AND date modified?

    You would need two field for this.

    The date created field is easily handled using the method recommended already.

    However, the date the record is modified is a little more tricky. You can do it on a form. In the AfterUpdate event of the detail, you can insert this code:
    If Me.Dirty = True then 'the Dirty propery shows whether the record has been changed or not
    Me.txtModifiedDate = Now() 'where me.txtModifiedDate is the name of the text box bound to the ModifiedDate field
    End If

  5. #5
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    Hmmm...

    I've got a date created field, and then I just set the value of the update form to Now(). Since they can only update the record via the ASP form, this will work.

    However, I will file your technique for later raference, in case I need to store that info via an Access form.

    Thanks!

  6. #6
    Join Date
    Nov 2002
    Posts
    37

    ?

    I read this reply and thought it a good idea to implement a date modified field for the record.
    I am not an expert with VBA, not that you need to be by the looks of this code, but I am having some problems getting it to work.
    Further explanation would be greatly appreciated.

    My main problem I guess is where to put the code exactly...

  7. #7
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    I'm doing it in ASP...

    I'm using ASP, not VBA, so I don't know if this will help you. On the Web form, I have a field called DateModified. Inside it I have the Now() function. In the HTML editor (Dreamweaver MX), the code is:

    <input type="hidden" name="DateModified" id="DateModified" VALUE="<%= Now() %>">

    And it works great. The current date/time stamp is added every time the record is updated.

    Note that I repeated duplicated the name and id properties: this is to help with compatibility with older browsers. Some old versions of Netscape prefer the ID tag, whereas Microsoft prefers the NAME tag. Using both prevents problems, and is perfectly safe in all newer browsers, as long as the name is identical.

  8. #8
    Join Date
    Nov 2002
    Posts
    37
    I am looking to do this in the Access form itself although I appreciate your reply !

  9. #9
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    ASP only...

    Sorry, pal, can't help with Access itself. I'm doing all my connecting via ASP. I'm sure someone here can help, though.

    Good luck.

  10. #10
    Join Date
    Dec 2002
    Posts
    1
    Try this:
    In the form's design view, right click to access the form's properties (that is the little square in the top left corner!)

    Under the Event tab, click on "On Dirty" and select Event Procedure.

    Click on the "..." next to it and then enter the following VB func
    Private Sub Form_Dirty(Cancel As Integer)
    Me.[Date Modified] = Now()
    End Sub

    ... substituting whatever is the name of your Date Modified field.

    Does that help? Works for me.

  11. #11
    Join Date
    May 2003
    Posts
    16

    Re: ?

    Hi,

    I have a small Access Database which is updated using an ASP Form, the form has all the shipping information fields. I would like to add a date and time stamp. When someone is filling out the form, the time and date stamp should automatically be entered in the database and when I view the details of that entry I should be able to see the date and time stamp. Can someone please help me.

    Thank you,

    Sajeed

  12. #12
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    Datestamp with Now() function...

    Dude, this is VERY easy in Access and ASP.

    You could do it in your ASP form, but I suggest you do it in your database. I suggest this in case you ever decide to upgrade to SQL: if you put the function in the ASP, it will not work in SQL. Also, if you do it in your database, the creation stamp cannot be overwritten later when someone edits the data via the ASP form.

    Nevertheless, here are instructions for both.

    ----------------------
    ACCESS INSTRUCTIONS:
    1. In ACCESS, go to Design View to create a new field. Call it Datestamp, or whatever.
    2. Set the Data Type to Date/Time
    3. Under default value, enter this: Now()
    ----------------------

    That's it. It will now enter the complete date and time whenever the record is created.


    ----------------------
    ASP INSTRUCTIONS:
    1. In your ASP form, create a hidden field called Datestamp
    2. Open an ASP tag inside the value parameter
    3. set the value to Now()

    That's it.

    Here's a sample of the HTML:
    <input type="hidden" value = "<%= Now() %>" name="Datestamp">

    Remember, this only works on a form on an ASP page. And also remember, if people will be editing data with this form, they will overwrite the Datestamp when they submit the form. That's why I suggest you use the Access method above.



    Good luck!
    Last edited by buzzter66; 05-23-03 at 12:22.

  13. #13
    Join Date
    May 2003
    Posts
    16
    Thank you so much for helping me out. It worked. One more thing though, if someone edits the record, can I show that as well under the record created field so that I know when was the item entered and when was it edited. Thanks for your help in advance.

    Sajeed

  14. #14
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85

    Create a second field called Edited...

    Create a second field called Edited. Use this field to track when people save changes. You should put this field in the ASP form so that it will change every time they save a change.

    Just remember, if you upgrade to SQL Server, then you will have to change the function. Now() does not work with SQL.

    Good luck!

  15. #15
    Join Date
    May 2003
    Posts
    16
    Can you please explain me in detail like last time, here's what I did so far. First I made a new field in my Access DB called Modified. And then as a default value I added Now(). Then instead I followed your same steps for the asp form and added a hidden field in my edit form. But it didn't work.

    I have one access db. One view.asp form, one add.asp form and one edit.asp form. My record creation time stamp works perfect. What I want is that when someone uses the edit.asp form to modify some record. I should be able to see both in my view.asp form like when was the record created and when it was edited.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •