Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
From 1 combobox to another
Message
De
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:
00393666
Vues:
19
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform