Discussion:
Messing up with a combobox
(too old to reply)
ViLco
2011-09-26 17:06:06 UTC
Permalink
This is the first time a combobox acts like this, maybe because it's the
only one linked to a table with a numeric field as the rowsource and a
numeric controlsource... It shows 2 columns from a linked table, NCODICE
(numeric autoincr) and DESCRIZ (the description). The boundcolumn is the
first (NCODICE), controlsource is a field in the main table where I
store the value of NCODICE from the linked table.
When I select a row having a certain value, the value which gets stored
in the main table is not NCODICE, it's the recno of the linked table. I
checked the value of both the field and the combobox.value and they all
show the value of recno() of the linked table instead of the value of
its NCODICE field.
Why? In my other comboboxes the combobox.value and the value stored in
the main table is the value of the field in the linked table.
Boundcolumn is set to 1, the rowsource is "CLIENTI,NCODICE,DESCRIZ", it
all looks allright but I can't allow it to work with recno instead of
the real value: at the first record deletion I would end up storing and
showing the wrong information, or no description...
This is puzzling me, anyone has any advice?
--
Vilco
And the Family Stone
Anche un maiale puo' arrampicarsi su un albero quando e' adulato
Dan Freeman
2011-09-26 18:42:18 UTC
Permalink
This is the first time a combobox acts like this, maybe because it's the only
one linked to a table with a numeric field as the rowsource and a numeric
controlsource... It shows 2 columns from a linked table, NCODICE (numeric
autoincr) and DESCRIZ (the description). The boundcolumn is the first
(NCODICE), controlsource is a field in the main table where I store the value
of NCODICE from the linked table.
When I select a row having a certain value, the value which gets stored in
the main table is not NCODICE, it's the recno of the linked table. I checked
the value of both the field and the combobox.value and they all show the
value of recno() of the linked table instead of the value of its NCODICE
field.
Why? In my other comboboxes the combobox.value and the value stored in the
main table is the value of the field in the linked table. Boundcolumn is set
to 1, the rowsource is "CLIENTI,NCODICE,DESCRIZ", it all looks allright but I
can't allow it to work with recno instead of the real value: at the first
record deletion I would end up storing and showing the wrong information, or
no description...
This is puzzling me, anyone has any advice?
Set the combo's BoundTo property to .t.

It's stunningly unclear in the docs, but this property was added to
combos to address exactly this problem.

Dan
ViLco
2011-09-27 08:55:55 UTC
Permalink
Post by Dan Freeman
Post by ViLco
This is puzzling me, anyone has any advice?
Set the combo's BoundTo property to .t.
It's stunningly unclear in the docs, but this property was added to
combos to address exactly this problem.
Dan, you're probably right on spot! This part of the VFP8 guide *exactly*
describes my issue:

".F. (Default) The Value property is determined by data type of the variable
or field specified in the ControlSource property.
If the variable or field specified in the ControlSource property setting is
of character type, the Value property is determined by the List property.
If the variable or field specified in the ControlSource property setting is
of numeric type, the Value property uses the index number from the ListIndex
property."

And the combo where I have that issue has a numeric ControlSource, eh eh eh.
I'll be testing it in 3 hours but I'm already positive this will correct my
issue, thanks :)
--
ViLco
Let the liquor do the thinking
ViLco
2011-09-27 12:59:16 UTC
Permalink
Post by ViLco
Post by Dan Freeman
Set the combo's BoundTo property to .t.
It's stunningly unclear in the docs, but this property was added to
combos to address exactly this problem.
And the combo where I have that issue has a numeric ControlSource, eh
eh eh. I'll be testing it in 3 hours but I'm already positive this
will correct my issue, thanks :)
Confirmed, it's all OK now. Thanks again, Dan
--
ViLco
Let the liquor do the thinking
Loading...