Subject | Re: Raising the DefaultValues/LookupCombo issue again |
---|---|
Author | Marco Menardi |
Post date | 2002-12-02T22:52:40Z |
Well, you are right in what you say, but, only with things organized
like yours.
I don't full understand the logic of your application.
In similar circumstances, I let the field having the NULL value, that
means "no key is here to link to a lookup table". You, on the
contrary, want to force values have 0 in this case (maybe because null
are hard to manage?).
A part from adding code to the client side, you can just put as "non
required" the field attribute, and force the 0 value in insert/update
triggers in the database.
If your modifications were included, how can the user set the field to
null? (canc will set to a default value...)
put this situation
a) I let the lookup key field have null value
b) I provide a default value to the field, so usually the user has the
field filled with the right value
c) the user want's not to set any link of the field to the lookup
table, so hits "canc", but this does not blank the field!
Put a table of people and a field of "favourite book" that lookups
onto the books table. The default value is the the most lended book of
the library.
If a person has no "favourite book" you have to set the field to null.
It would be really bad having a "fake" book with the title "NO ONE" in
the books table...
How would you solve this?
regards
Marco Menardi
like yours.
I don't full understand the logic of your application.
In similar circumstances, I let the field having the NULL value, that
means "no key is here to link to a lookup table". You, on the
contrary, want to force values have 0 in this case (maybe because null
are hard to manage?).
A part from adding code to the client side, you can just put as "non
required" the field attribute, and force the 0 value in insert/update
triggers in the database.
If your modifications were included, how can the user set the field to
null? (canc will set to a default value...)
put this situation
a) I let the lookup key field have null value
b) I provide a default value to the field, so usually the user has the
field filled with the right value
c) the user want's not to set any link of the field to the lookup
table, so hits "canc", but this does not blank the field!
Put a table of people and a field of "favourite book" that lookups
onto the books table. The default value is the the most lended book of
the library.
If a person has no "favourite book" you have to set the field to null.
It would be really bad having a "fake" book with the title "NO ONE" in
the books table...
How would you solve this?
regards
Marco Menardi
--- In IBObjects@y..., "Eric Handbury" <ehandbury@h...> wrote:
> Hello,
>
> I must raise the DefaultValues and LookupCombo issue again,
> because (IMO) the functionality is wrong.
>
> For example, if I have a field KEYVALUE which is linked to a
> LookupCombo box, I will show 2 examples in which 1 works and 1
> doesn't. (DefaultValue entry: KEYVALUE=0, and KEYVALUE is a required
> field in the Table)
>
> Example 1 (works):
> 1) User starts an insert and enters nothing into the KEYVALUE
> LookupCombo. (field is blank.)
> 2) User hits the Commit button.
> 3) Insert works because KEYVALUE=0 since I have specified that in
> the DefaultValues list.
>
> Example 2 (doesn't work):
> 1) User starts an insert and clicks on a entry in the LookupCombo
> list.
> 2) User says 'Ooops' and hits the DEL button to remove the entry
> in the LookupCombo (field is now blank just like in Example 1).
> 3) User hits the Commit button.
> 4) A IBO EIB_DatasetError exception is generated saying 'KEYVALUE
> is a required field'. This is because hitting the DEL button sets
> the KEYVALUE field to NULL.
>
> There are only 2 possible solutions:
> 1) IBO returns the KEYVALUE field to 0 after the user hits the DEL
> button since this is the DefaultValue that I have specified the
> field to have. This is the correct thing to do.
> 2) I have to put logic in every one of my BeforePost events and
> check the value of every one of my LookupCombo fields to see if they
> are NULL and change them to 0. This is what I must do now, and is
> not the correct solution.
>
> Eric.