How to timestamp a new record

Creating and using forms

How to timestamp a new record

Postby hypGnosis » Thu Jan 09, 2020 3:21 am

Using Base Forms, is it possible to timestamp (auto populate a field like "Record Created Date & Time")
OpenOffice 4.1.7 on Windows 10
hypGnosis
 
Posts: 13
Joined: Fri Apr 26, 2013 10:40 pm

Re: How to timestamp a new record

Postby Villeroy » Thu Jan 09, 2020 1:43 pm

This is a feature of the underlying database.
Using HSQL:
menu:Tools>SQL:
Code: Select all   Expand viewCollapse view
ALTER TABLE "TBL" ADD COLUMN "TS" TIMESTAMP DEFAULT CURRENT_TIMESTAMP

menu:View>Refresh Tables

Now every new record gets a timestamp in column TS unless you explicitly enter some date-time value.
On the form you either leave out the TS field or you add a label to it like "Timestamp (Blank=Now)".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28220
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to timestamp a new record

Postby hypGnosis » Tue Jan 14, 2020 10:36 pm

Thank you for your reply, Villeroy. I've looked & looked all over (even in a LibreOffice forum), but to no avail. I am looking for a routine that would update the current record with a record creation timestamp; and if the record had previously been created, then the routine would opt for updating the Last Edited (recEdit) timestamp and not change the recCreate field. I was also looking for a routine that would find the time difference in two of the form's fields (Time Start & Time Stop) and display the difference in a textbox on the form and not save a calculation in the table ... only display it on the form every time a different record is displayed. No luck there either.

Now, I did not try your suggestion because I already have a recCreate field/column define in the table; and, I think that every time I executed your suggested SQL, I would have another, and then, another, and so on, every time I added a new record. The file might end up with a lot of "TS" fields.
OpenOffice 4.1.7 on Windows 10
hypGnosis
 
Posts: 13
Joined: Fri Apr 26, 2013 10:40 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 3 guests