Normal Topic Date Stamp (Read 1216 times)
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Date Stamp
Nov 18th, 2012 at 7:09pm
Print Post Print Post  
I would like to insert a field into my application where upon entering a new record it automatically enters the current date: mm/dd/yyyy.
Hopefully thie original date will not change upon making editing changes to a previously saved record.

Thanks,
Peter
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Date Stamp
Reply #1 - Nov 18th, 2012 at 10:06pm
Print Post Print Post  
I keep a record of the date & time the record was added, and also the date & time of the last change to the record (you can omit the parts you don't want to use). Put something like this in the On Form Change event:
Code
Select All
If @IsNew
{
	If @IsBlank(DateAdded)
		DateAdded = @ServerDate()
	If @IsBlank(TimeAdded)
		TimeAdded = @ServerTime()
}

DateChanged = @ServerDate()
TimeChanged = @ServerTime() 



Don't forget to make the LEs read-only.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Date Stamp
Reply #2 - Nov 20th, 2012 at 6:09pm
Print Post Print Post  
BTW, you don't really need the @IsBlank() conditionals. It's optional, depending on whether you want to store the time that the user began to add anything to the new record, or the time that the user finished adding anything to the new record.

Using the code example I provided above (along with the two "...Changed" fields), I can see how much time the user spent adding the record. By using the @IsBlank() conditionals, the two "...Added" fields are only populated when they begin adding a new record, and the two "...Changed" fields are updated upon every change to the record, effectively showing me the times they began and finished (assuming that someone didn't update the record later).

Having the two "...Changed" fields can be very helpful in tracking what records have been changed recently.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged