I've got a number of checkboxes that are ticked as an when certain tasks are done.
Is there a way to easily record the date when these were ticked, without having to add adate field to the form?
Or will I need the date field?
Logging date on check box
Logging date on check box
OpenOffice 4.1.3
Windows 7
Windows 7
Re: Logging date on check box
You could write a bit of code to do an SQL update of a date field when the check box is ticked. It's easy, but you may not have written code before?
OpenOffice 4.1.12 on Windows 10
Re: Logging date on check box
No, Sadly never written code.
I'll just build a date field into the table rather than a tick box.
I'll just build a date field into the table rather than a tick box.
OpenOffice 4.1.3
Windows 7
Windows 7
Re: Logging date on check box
The attached document is a demo on default values with a default date in the "Data" table and a time stamp in the related "Check" table. This is a one-to-one relation where every record in "Data" may have one or zero records in table "Check".
How I added the default date in "Data" using Tools>SQL... (not possible in the graphical user interface):
How I added the time stamp
How I linked the two tables by adding a foreign key to the "Check" table (can be very tricky to do in the GUI):
The form:
The subform shows the related "Check" record for the selected "Data" record in the parent form.
The forms are linked by their common ID fields, the time stamp controls are read-only, the save button marked as default button (reacts on Enter key).
When you check the box of an empty "Check" record and either push the save button or move back to the parent form, then you store a new record in the "Check" table which marks the related "Data" record as checked. The new record gets an automatic time stamp.
You can uncheck a record either by unchecking the boolean field (which keeps the original time stamp) or by deleting the "Check" record alltogether.
The default date in the "Data" form is today's date if the user does not enter any other date.
Unfortunately, I don't know any way to show this one-to-one relation in a single grid AND keep the grid editable. You can merge both tables in a read-only query as shown by query "qMerge".
How I added the default date in "Data" using Tools>SQL... (not possible in the graphical user interface):
Code: Select all
ALTER TABLE "Data" ALTER COLUMN "Date" SET DEFAULT CURRENT_DATE;
Code: Select all
ALTER TABLE "Check" ALTER COLUMN "TS" SET DEFAULT CURRENT_TIMESTAMP;
Code: Select all
ALTER TABLE "Check" ADD FOREIGN KEY ("ID") REFERENCES "Data" ("ID");
The subform shows the related "Check" record for the selected "Data" record in the parent form.
The forms are linked by their common ID fields, the time stamp controls are read-only, the save button marked as default button (reacts on Enter key).
When you check the box of an empty "Check" record and either push the save button or move back to the parent form, then you store a new record in the "Check" table which marks the related "Data" record as checked. The new record gets an automatic time stamp.
You can uncheck a record either by unchecking the boolean field (which keeps the original time stamp) or by deleting the "Check" record alltogether.
The default date in the "Data" form is today's date if the user does not enter any other date.
Unfortunately, I don't know any way to show this one-to-one relation in a single grid AND keep the grid editable. You can merge both tables in a read-only query as shown by query "qMerge".
- Attachments
-
- one2one_stamp.odb
- One-to-one demo with check box and time stamp.
- (13.46 KiB) Downloaded 111 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice