# Libreoffice Base: Need today’s date as default value in a form field

datelibreofficelibreoffice-base

New to libreoffice Base. I've found how to set the default value in a table to the current date. Now I need to have the current date show up in the corresponding field in a form. I have tried inserting into "default value" TODAY() and CURRENT_DATE. They both give me Nov. 18, 1899 for some reason. And ideas how to do this?

Use the following macro code. Here, the table's column (not the control name) is called "MyDate".

Sub DefaultDateInForm (oEvent As Object)
oForm = oEvent.Source
lDateCol = oForm.findColumn("MyDate")
If oForm.getString(lDateCol) = "" Then
dateStamp = Format(Now, "YYYY-MM-DD")