Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
From 1 combobox to another
Message
 
À
18/07/2000 03:18:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00391237
Message ID:
00393799
Vues:
16
Sounds like alot of code there. I was fooling around and accomplished by putting this into the gotfocus event of the combobox1:
[thisform.myCombobox1.RowSourceType = 3
thisform.myCombobox1.RowSource = "SELECT name,noun from bsyear00 WHERE subs(bsyear00.noun,2,3) $ thisform.mytextbox2.value INTO cursor cur1"]
and it worked.




>Hi Timothy.
>
>>> Where would I put the code to set the value of combo2 (judging from the value of combo1)? <<
>
>Assume you have 3 controls on a form:
>
>An option group bound to a form property called Thisform.nType, a combo box called cboCategories bound to a form property called Thisform.nCategory, and a listbox called lstDetails bound to a form property called Thisform.nDetail. The combo and list are both set up with 2 columns, boundColumn = 2 and BoundTo = .T.
>RowSourceType=3-SQl.
>
>This code, in the form's init, initialized the combo and list boxes:
>
>
>LOCAL lcRowSource
>*** Set up the SQL statement to use as the RowSource for the Categories combo box
>*** Select only the items that have a Cat_No equal to the option selected in the option group
>*** The option group is bound to Thisform.nType and that property is initialized to 1
>lcRowSource = 'SELECT Cat_Desc, Cat_Key, UPPER( Categories.Cat_Desc ) AS UpperDesc '
>lcRowSource = lcRowSource + 'FROM Categories WHERE Categories.Cat_No = ( Thisform.nType ) '
>lcRowSource = lcRowSource + 'INTO CURSOR csrCategories ORDER BY UpperDesc'
>*** Now set up the combo's properties
>WITH Thisform.cboCategories
>	.RowSourceType = 3
>	.RowSource = lcRowSource
>	*** Don't forget to repopulate the control's internal list
>	.Requery()
>	*** Inialize it to display the first item
>	.ListIndex = 1
>ENDWITH	
>*** Set up the SQL statement to use as the RowSource for the detail list box
>*** Select only the items that have a De_Cat_Key equal to the Item selected in the combo box
>lcRowSource = 'SELECT Det_Desc, Det_Key, UPPER( Details.Det_Desc ) as UpperDesc FROM Details '
>lcRowSource = lcRowSource + 'WHERE Details.De_Cat_Key = ( Thisform.nCategory ) INTO CURSOR csrDetails '
>lcRowSource = lcRowSource + 'ORDER BY UpperDesc'
>*** Now set up the list box's properties
>WITH Thisform.lstDetails
>	.RowSourceType = 3
>	.RowSource = lcRowSource
>	*** Don't forget to repopulate the control's internal list
>	.Requery()
>	*** Inialize it to display the first item
>	.ListIndex = 1
>ENDWITH	
></re>
>
>Now, this code in the option group's valid, requeries the combo and list boxes based on what is selected in the option group:
>
><pre>
>WITH Thisform
>	.cboCategories.Requery()
>	.cboCategories.ListIndex = 1
>	.lstDetails.Requery()
>	.lstDetails.ListIndex = 1
>ENDWITH	
>
>
>And this code in the combo's valid, requeries the dependent list box:
>
>
>WITH Thisform
>	.lstDetails.Requery()
>	.lstDetails.ListIndex = 1
>ENDWITH	
>
>
>SET PLUG ON
>The sample above came from Chapter 5 of "1001 Things You Wanted to Know About Visual FoxPro" co-authored by me, Andy Kramek, and Rick Schummer and published by Henztenwerke publishing.
>
>You may want to pick up a copy. I think you could find it very useful < s >.
>SET PLUG OFF
>
>Marcia
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform