Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo Box
Message
De
26/10/1998 11:10:20
 
 
À
26/10/1998 09:47:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00150414
Message ID:
00150517
Vues:
19
>>>>I have on a form an option group and a drop down combo box. The items shown in the drop down combo box are depending on the option chosen in the option group. The row source type of the combo box is 3-SQL Statement. In the interactive change event of the option group I change the SQL statement for the combo box row source accordingly.
>>>>The control source of the drop down combo box is bound to a field in the underlying table of that form.
>>>>
>>>>Everything works fine. If an option is chosen the relevant items only are shown in the drop down combo box. If I click on an item of that list the correct item is saved in the field of the underlying table.
>>>>
>>>>However, when I navigate through the records, only values are shown in the textbox part of the drop down combo box which correspond to the SQL statement of the last chosen option.
>>>>E.g. if the last option chosen was option 3 the values in the text box part of the combo box are only shown for records with have option 3 chosen. In records with option 1 or 2 and so on chosen the text box part of the drop down combo box is empty although the field in the underlying table bound to the drop down combo box has a correct value stored in it
>>>>It seems, that the SQL statement in the row source of the drop down combo box acts like a filter for what is shown in the text box part.
>>>>I wonder if that is inherent to combo boxes used in that context or whether I do something wrong.
>>>>
>>>>I have found some workarounds (e.g put in to the lost focus event of the combo box a SQL statement that selects all options) but none of them are very satisfying.
>>>>
>>>>I am new to VisualFoxPro (coming from Access) and would be grateful for any help or hints in that matter.
>>>>
>>>>Thanks
>>>>
>>>>Josef
>>>
>>>That's normal behaviour: drop-down list can store in its Value property (text portion) only values from list portion. You can get much more flexibility (and power) if you don't bind combo.controlsource to table.field, and populate combo.rowsource from cursor.

>>
>>Thank you very much for your quick reply. As I said I am new to Vfp so let's see whether I understand the concept of the controlsource correct. I thought that in the controlsource property of a combo box one enters the fieldname of a table in which the value of the item a user has selected is stored. Now, if I do not bindthe combo box to a table field how get's the selection from the combo box than stored?
>>
>>I populate the list from a cursor. That is I use as rowsource a SQL statement with the following form "select from lookup table where option=optiongroup value into cursor "
>>
>>Josef
>
>You understand controlsource right, but combo itself expects to get Value property (which is actually going to contolsource location) from its list portion and if you don't have this item there, then combo gets confused. My preference is to separate table from controls and move data in/out programmatically (you will find many people around who do opposite). Exchanging data between table and combo (or any other control) can be done by populating Value property when form gets new record and populating table.field by control.value when edit session is finished. Cursor is better than SQL mostly because of internal quirks, i.e. again when you SELECT ... Into Cursor and then substitute this alias as Combo.RowSource you get one more entry point to control application flow, and controlling of application flow is really important thing in VFP.

Ed,
thanks again for your quick reply and patience with a novice. I may have further questions to that subject but I have first to digest your reply's. Especially the separation from tables and controls sounds interesting. Is this done in a similar way like writing data into a variable and when editing is completed replace the fields with those values? I thought with Vfp's buffering this way of writing data to a table is not needed anymore? I have read almost all the books available on Vfp and they helped me a lot to be sure. But as always books are one thing hands on experience another.

Josef
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform