Using PriorToReset event in Base form

Please correct me if I'm wrong, and if there's a better place to ask, let
me know.

It is my understanding (experimentally verified) that the PriorToReset
event will fire when a new database row is produced for data entry. Inside
this event, I can use the passed in event object to get the Form and from
the form get at the elements of the form.

I named my sub the same as the event it relates to.

Sub PriorToReset(event)
dim Form
dim DateField
Form=event.source
DateField = Form.getByName("Date")

Now I can drop a date into the "Date" field via :
DateField.setPropertyValue("Text",
​"01/04/2015"​
)
​
That date shows up on the screen as though I had keyed it in by hand. Great
so far.

Once I fill out the remaining fields manually, and an attempt is made to
send the data to the database, an error shows up asking to fill in the
mandatory "Date" field. I'm looking at it filled in exactly as I want it,
but somehow the system thinks it's not filled in. If I focus the date field
and backspace over the last digit (5) and then re enter 5 and hit enter,
and then attempt to save the record, it works. Why?

​Why can I see the date field filled in exactly as I want it, but somehow
the system thinks the field is empty or somehow invalid until I touch the
field and tinker with its last digit. If I set the last digit to 9, for
example, a database row is stored with 01/04/2019 in it as expected.

Sorry Bill,

I could have added a bit more explanation regarding the code I sent you.
Basically, it looks at the form object to see what sort of control you want
to store a value in, and then chooses either the Date code or the other
alternative for all other control types.

I should have added that I am running an H2 Database on Windows 7. I have
found in the past that my code doesn't always translate to other
Databases/Operating Systems, but in this case I thought the code would
probably be Database/System independent.

So, I would suggest that you try running the code first to see if it works
for you. If it does, then I could help you to understand how it ticks
should there be any parts that were unclear to you. If it doesn't work,
then you would not have spent time on something that you can't use.

My 2c worth!

Noel