>>>Hello All,
>>>I have a requirement to produce a drop down combo, that displays a field from a table, and allows the user to add a record by typing directly into the combo and hitting enter, any ideas would be appreciated as I don't have much time
>>>
>>>TIA
>>>
>>>Pete Kane
>>Pete,
>>There is a sample in Tasmanian Traders. A quick and simple coding could be :
>>
>>this.value = this.displayvalue
>>if !seek(upper(this.displayvalue), "myLookup","UpperedLookupTag")
>> insert into myLookUp (lookupfield) values (upper(this.displayvalue))
>> insert into myTable (myField) values (mylookup.lookupfield)
>>endif
>>this.displayvalue = this.value
PS: Not tested, might need corrections.
>>Cetin
>
>
>Hi Cetin,
>long time no hear, thanks, BTW why the two inserts?
>
>
>Regards
>
>Pete
First to update your lookup table, second your data table.
If you don't want to update your lookup table then you could set combo's rowsourcetype to SQL and do a select union to also include records that are in lookup table. Otherwise your combo wouldn't display value.
What I do is not to use a lookup table but do an SQL on the table itself with a union ;) Something like this :
select distinct myField from myTable ;
union ;
select this.value as myField ;
into cursor myCursor
and I requery() the combo in gotfocus + navmovements. Union is needed to include "new" value in a buffered table.
Cetin