Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding records with a Combobox
Message
From
19/08/1999 10:50:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00255190
Message ID:
00255284
Views:
19
>>>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 :
>>
*Combo lostfocus
>>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform