Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cascading Combobox
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00278816
Message ID:
00278881
Vues:
19
>I need to use 3 comboboxes: cbo2 is dependent on cbo1 and cbo3 is dependant on cbo2.
>When tha choice has been made in cbo1 I need to have a SQL SElECT cbo2 to make the choices available and the same thing from cbo2 to cbo3.
>I would need to know how to do this.
>
>Thanks in advance

Hi Raymond.

As colin said, you would put cbo2.requery() and cbo3.requery() in the valid method of cbo1. If you are going to set up the sql for the RowSources of the combos using a reference to Thisform.cbo1.value, you will get a runtime error saying that you can only use Thisform in a method. If you set up the rowsources in the individual combo's inits, you may run into problems if cbo3 is instantiated before cbo1. So the safest place to set up the rowSources is in the form's init using code something like this:
LOCAL lcRowSource
*** Set up the SQL statement to use as the RowSource for combo2
*** Select only the items that match the value in combo1. This assumes that 
*** something is selected in combo1 or that it has been initialized  by
*** setting This.ListIndex = 1 in combo1's init
lcRowSource = 'SELECT yada, nada, blah '
lcRowSource = lcRowSource + 'FROM MyTable WHERE MyField = ( Thisform.Combo1.Value ) '
lcRowSource = lcRowSource + 'INTO CURSOR MyCursor'
*** Now set up the combo's properties
WITH Thisform.combo2
	.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 third combo
*** Select only the items that match the selected item in combo2
lcRowSource = 'SELECT Burp, Slurp, Chirp FROM MyOtherTable '
lcRowSource = lcRowSource + 'WHERE MyOtherFied = ( Thisform.Combo2.Value ) INTO CURSOR MyOtherCursor '
*** Now set up the combo's properties
WITH Thisform.combo3
	.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	
Marcia
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform