Hi Bill, I also encountered this problem. It turns out that you need to update the Control's bound field. Below is a modified version of a Macro I use. To update most Controls is fairly straightforward, but a Date Control is a bit more complicated. As you can see, you pass the Control Name, the new Value and the Form object to the Macro.
In your case I think if you called - libUpdateControlValue("Date", "2015-01-04", DateField) you will get the result you want. Sub libUpdateControlValue(sControlName AS String, sNewValue AS String, oControl AS Object) Dim DateStruct AS new "com.sun.star.util.Date" Dim sDateValue AS String Dim sControlType AS String sControlType = oControl.DataFieldProperty if Instr(1,"Text,EffectiveValue,SelectedItems",sControlType) > 0 then oControl.boundfield.updateString(sNewValue) ' Sets the new value in the boundfield Object End if if sControlType = "Date" then sDateValue = sNewValue ' to prevent sNewValue being changed! if len(sDateValue) = 10 then ' = yyyy-mm-dd sDateValue = left(sDateValue,4) + mid(sDateValue,6,2) + right(sDateValue,2) ' = yyyymmdd End if DateStruct.year = left(sDateValue,4) DateStruct.month = mid(sDateValue,5,2) DateStruct.day = mid(sDateValue,7,2) oControl.boundfield.updateDate(DateStruct) ' Sets the new value in the boundfield Object End if End Sub Let me know if you have any problems. Noel -- Noel Lodge lodg...@gmail.com On 5 January 2015 at 06:39, Bill Gradwohl <b...@ycc.com> wrote: > 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. > > -- > Bill Gradwohl > > -- > To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org > Problems? > http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ > Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette > List archive: http://listarchives.libreoffice.org/global/users/ > All messages sent to this list will be publicly archived and cannot be > deleted > -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted