Subject Re: [IBO] resetting field values to their defaults
Author Raymond Kennington
Jane Obenza wrote:
>
> > However, I'm really puzzled about why you want to do things this way.
> Keys
> > should not be editable. An "edit" that changes the key and sets all other
> > columns to default values isn't an edit - it's an insert. If you want a
> > new row to replace an existing row, have a sequence that inserts the new
> > row and deletes the one with the old key. That way, DefaultValues kick in
> > automatically, as designed, and the whole process is squeaky clean.
> >
>
> Hi Helen,
>
> Sorry, my mistake. Yes, it actually is an insert. The user enters an ID
> number, which is the key field, then enters the values for all the other 20
> fields or so, for that particular ID number. My concern is that after the
> user has already entered values for some of the fields then he/she decides
> to change the ID number, I would like all the other fields to reset to their
> default values, which is 0, and the user can then start anew.
>
> So do I have to write my own code then? I was actually putting it off in
> case there is a better way :)
>
> Thanks,
> Jane

Add an internal field to be used as the primary key and use a generator for it.

The user should never see this internal field.

What you want to do is outside the realm of IBObjects.

Usually one would code this oneself in the OnChange event of the TField object
corresponding to the field. When a record is created you must store the initial
value. Upon a change, you must write code to update all the fields that you want
to.

The only way to get the IB/FB defaults to appear in IBObjects is to insert a
record.

You could iterate through the fields and set the defaults yourself.
--
Raymond Kennington
Programming Solutions
W2W Team B