Base Version 4.3.5.2 on Fedora 21.
I have a data entry form for an inventory database. The first field is a Date. The appropriate entry for the date field is almost always today’s date. Therefore, I want to programatically enter today’s date into the first field for the first new database row and if it’s incorrect for the occasion the user can change it. All additional rows should repeat whatever was entered in the previous row for date as the information is typically coming from a long invoice.
Option Explicit
Global defaultDate as string
Sub Main
defaultDate = Date
End Sub
Sub PriorToReset(event)
dim Form
dim DateField
MsgBox ("defaultDate = " + defaultDate) ' for testing
Form=event.source
DateField = Form.getByName("Date")
if DateField.getPropertyValue("Text") = "" then
DateField.setPropertyValue("Text", defaultDate)
MsgBox ("Setting default to " + DateField.getPropertyValue("Text")) 'for testing
else
defaultDate = DateField.getPropertyValue("Text")
end if
End Sub
First problem:
Using Xray, I can see that the code is working as expected. However, when the rest of the row is filled in, an error pops up saying the date field is empty. I’m looking at that field on the screen and it has today’s date in it but the system reacts as though it was empty. If I focus that field, and backspace over just the last digit and then replace that digit, it accepts the whole field as valid. i.e. if I see 01/03/2015 and backspace over the 5 and then key in the 5 all is well and a new row shows up. What am I missing?
Second problem:
The new row has a blank date field, but using Xray, the “Text” property has today’s date in it. There’s a disconnect here I don’t understand.