>
>What if the user enters the text and them presses < Enter >? Does it stay then?
Yes, with the code from Marcia it stays there. If I then go back to the combobox and re-type the value, both values stay in the list. This is untill I saved the data and requery combobox using actual tables rather than this select.
I guess there is no simple way around it (unless keeping all new entries in array ( or additional cursor) and deleting them from this cursor when a new value typed over the previous one). I'm wondering if this idea worth implementing or these bad new entries are not a big deal.
(The other idea is always replace the last physical record in the cursor with the new value)
What do you think?
UPDATE. Ok, while I was waiting your reply I went ahead and implemented this:
Init of the combo:
dodefault()
this.AddProperty('lValueInserted',.f.)
this.AddProperty('cValueInserted',"")
valid of the combo:
local lcValue, lcOldValue
lcValue = this.displayvalue
if not empty(m.lcValue ) and this.listindex = 0
if this.lValueInserted
lcOldValue = this.cValueInserted
replace cShort_Name with m.lcValue for cShort_Name == m.lcOldValue in curShortNames
else
insert into curShortNames (cShort_Name ) values (m.lcValue)
endif
this.requery()
this.value = m.lcValue
this.lValueInserted = .t.
this.cValueInserted = m.lcValue
endif
this.parent.chkDefault_Carrier.enabled = not empty(m.lcValue)
If it's not broken, fix it until it is.
My Blog