Access form date field data from base macro

I am designing a form in which the user will enter beginning and ending dates. I will use these dates in a macro to create an sql SELECT string. Unfortunately, I have been unable to determine how to access the data entered in the date field from my macro. My best guess at the code is:

Sub DateTest
DIM oStartBox as OBJECT 'This is a date field on oForm
DIM dDate as DATE

oForm = ThisComponent.Drawpage.Forms.getByName("sqlForm")
oStartBox= oForm.getByName("StartBox") 

dDate = oStartBox.getCurrentValue()     
msgbox dDate 

end sub

“StartBox” is a date field located on the “sqlForm”. I execute the macro using a push button on the form after entering a date in the date field.

I get the error message:
BASIC runtime error.
Incorrect property value.

This seems like it should be a very simple operation, and it probably is, but I am missing something.


You can find the answer in the LO documentation - LibreOffice Base Handbook in Chapter - 9 - Macros. Look in section - Converting dates from a form into a date variable (Page 37).

This post is about the same → Time&Datefield in Dialogue saving text instead of time&date.