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!
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
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...
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:
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.
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.
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.
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.
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()
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.
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.
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.