New Sample - How to manipulate records in a sub form using DatePicker()
The best way of doing this is by building our own "control". in DE8 you can manipulate objects by number. i SetValue("DateField") will set the value in the first DateField in the
form. In subforms DE clones the initial objects so all objects have the same name in each record, to work around this we have added a number option to the
Set functions i.e. SetValue("DateField#10",datepicker()) will set the date in the 10th datefield on the form.
One important thing to realise when manipulating objects is that they are only hosts for data, they are not linked to the data in records. The same way a Form is the same for
all records in the the table, the 10 subform records are host for any number of subrecords, so to link or DatePicker logic to the record is no good.
But do we have to bother with it at all? No. We do all this subform stuff because we want the data to be stored in flat structure, but the forms don't have to reflect this. This is
actually a perfect occasion to show how Form logic can be forged to work with data logic.
Above I have simply made one button for each row in the Subform, made the subform transparent and put the buttons under the subform so they look like they are part of
the subform. Each button manipulate a DataField object from 1 to 10. ex.
SetValue("DateField#5",DatePicker()) as an action on the button.
The brilliance of this is that it will always manipulate the field next to it, so when you scroll up and down in the subform it will still work.
COOL!
You an of course use all kinds of Set functions this way.