Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you add to a COMBO BOX?
Message
From
30/10/1997 12:37:57
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00057406
Message ID:
00057438
Views:
40
>>>Robert,
>>>
>>>Are you trying to allow the user to enter a value in the textbox area of the combobox and if what they typed doesn't already exist in the combobox add it to the combobox choices?
>>
>>Colin,
>>yes - I want to treat the combo like a field.
>
>Robert,
>
>I've done something similar. The combobox is a list of positions and allows the user to add new values. The code below is in the combobox's .Valid method. The combobox's RowSource is Position.Position and the ControlSource is People.Position.
>
>IF NOT SEEK(ALLTRIM(THIS.DisplayValue),"POSITION")
> mnadd=MESSAGEBOX("Do you wish to add this position type?",4+32+256,;
> ALLTRIM(THIS.DisplayValue)+" not found")
> IF mnadd=6
> INSERT INTO Position (Position) ;
> VALUES (THIS.DisplayValue)
> REPLACE People.Position WITH THIS.DisplayValue
> THISFORM.rtgPageFrame1.Page1.cmbPosition.Requery
> THISFORM.rtgPageFrame1.Page1.Refresh
> ELSE
> THISFORM.rtgPageFrame1.Page1.cmbPosition.DisplayValue=""
> THISFORM.rtgPageFrame1.Page1.cmbPosition.Value=""
> THISFORM.rtgPageFrame1.Page1.cmbPosition.SetFocus
> ENDIF
>ENDIF

Nice code, but the more common way is check in Combo.Lostfocus
IF This.DisplayValue!=This.Value && not any rowsource can be SEEK
**** add new record as you did here
Endif
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform