Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dreaded Combo Box Behavior
Message
De
03/06/1997 14:50:57
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00034772
Message ID:
00034818
Vues:
49
>>>>>>>>>I have a combo box (actually dropdown list (style=2)) listing different types of software to choose from. I populate this dropdown using rowsourcetype=SQL Select and rowsource="SELECT desc FROM software INTO CURSOR query".
>>>>>>>>>
>>>>>>>>>I want to populate another table (CALLS.DBF) with the value of the selection so I set the controlsource to "calls.softwaredesc".
>>>>>>>>>
>>>>>>>>>I would like to use this dropdown to serve the dual function of showing what was previously entered, and allowing the user to change the value of what was previously entered. My problem is that is a record that was previously entered has a softwaredesc that is no longer in the software table, it will not show as the value in the dropdown list.
>>>>>>>>>
>>>>>>>>>Does anyone have any simple workarounds?
>>>>>>>>
>>>>>>>>I see a problem: why 'previous' record.softwaredesc is no longer in the software table? It's obvious contradictory to data normalization rules.
>>>>>>>
>>>>>>>For simplicity's sake, I described it that way... but in reality, it is still in the table, just marked as inactive. There may be cases where a piece of software that might have been a valid choice two years ago, is no longer available today, therefore not a valid choice today. We mark that software as inactive (a logical field in the software table) to maintain the data link to historic data, but it still doesn't solve my combo box problem.
>>>>>>
>>>>>>If your combo includes 'inactive' software too, it shouldn't be a problem to get requested functionality resetting Value property. I ,personally, wouldn't use ControlSource property here.
>>>>>
>>>>>I tried explicitly setting the value property to the value of calls.softwaredesc, and it still comes up blank. Both with the ControlSource property used and unused.
>>>>
>>>> Is 'previous' softwaredesk in list portion of Combo or not? The basic idea of Combo.Style=2 is that both Combo.Value and DisplayValue going from List portion exclusively. If Style=0 you can use DisplayValue which reflects something you typed in text portion but didn't add to list portion yet.
>>>
>>>as an example, let's say that calls.softwaredesc='Word 5.0'. Let's also say that 'Word 5.0' is in software.dbf, but is marked as inactive. I do a:
>>>
>>>select desc from software where inactive=.f. into cursor query for my rowsource
>>>
>>>Therefore, Word 5.0 is not in my dropdown list. when a user brings up that call record, I want it to say 'Word 5.0', even though it isn't an option on the dropdown list. I also don't want them to be able to just add any text they want in that field. I want to force them to choose one of the dropdown options (if they are going to change it). That is why I set style to 2 instead of 0. It is very likely they are just looking at the record for historical purposes and wouldn't need to or want to change it. But they definately need to SEE it, and still have the option to choose from the list of active software descriptions.
>>
>>As I told you, the only way to provide, that text portion of combo differs from any list protion item, is to make:
>>1. set Combo.Style=0 and
>>2. set Combo.Displayvalue=previousvalue
>>BTW, it's easy to prevent users from typing into text portion- look at KeyPress event of the combo. So, you will get your functionality!
>
>Just one more question, where should I put the code to set the Combo.Displayvalue=previousvalue (calls.softwaredesc))? I tried putting it in the refresh method, and it didn't work.

It should work from any place, remember two things: Combo.Style=0 and check that your ControlSource doesn't override DisplayValue (that's the reason why I don't like to use ControlSource).
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform