*Form.init *Previous combo init code with this.Grid1 .RecordSource = "" .RecordSourceType = 4 .RecordSource = 'Select distinct * '+; ' from neil' ' where moc034 = trim(crsProduct.Type) and'+; ' moc011 = trim(crsSubProduct.SubType)'+; ' into cursor crsresult' endwithHere is a sample using Customer table ( assume Country=Type and City=SubType)
*Form.init With This.Combo1 .RowSourceType = 3 .RowSource = ' select country,Upper(country) as ID where !Empty(country) from customer'+; ' union'+; ' select "--All--" as country,"" as ID from customer'+; ' order by ID'+; ' into cursor crsCountry' .ListIndex = 1 Endwith With This.Combo2 .RowSourceType = 3 .RowSource = ; 'select city,Upper(city) as ID from customer where !Empty(city) and '+; ' Upper(country) = Trim(crsCountry.ID)'+; ' union'+; ' select "--All--" as city,"" as ID'+; ' from customer'+; ' order by ID'+; ' into cursor crsCity' .ListIndex = 1 Endwith With This.grdCustomer .RecordSourceType = 4 .RecordSource = 'select cust_id,company,city,country'+; ' from customer'+; ' where Upper(country) = Trim(crsCountry.ID) and'+; ' Upper(city) = Trim(crsCity.ID)'+; ' into cursor crsCustomer' Endwith *Combo1.InteractiveChange - note that .RecordSource = .RecordsSource implies refresh With this.Parent.combo2 .Requery() .ListIndex = 1 EndWith With this.Parent.grdCustomer .Recordsource = .Recordsource endwith *Combo2.InteractiveChange - note that .RecordSource = .RecordsSource implies refresh With this.Parent.grdCustomer .Recordsource = .Recordsource endwithNote that there is no reference to combo.value or displayvalue. Who cares, we directly get the value from its cursor, any field we want (ie:crsCountry.ID which is a calculated field in cursor and combo columncount is in its default 1). Modify code with your table and fieldnames and you should be OK :)
>recordsource='Select distinct * from neil'+; ' where thisform.combo1.displayvalue=moc034 and thisform.combo2.displayvalue=moc011'+; ' into cursor crsresult' > >recordsourcetype=4 >>
>SET EXCLUSIVE OFF >SET DEFAULT TO ("C:\Foxpro Projects\Statistics") > >with thisform.combo1 > .RowSourcetype = 3 > .Rowsource = 'Select distinct type from products order by type into cursor crsproduct' > .ColumnCount = 1 >ENDWITH > >with thisform.combo2 > .RowSourcetype = 3 > .Rowsource = 'Select subtype from products where type=crsproduct.type order by subtype into cursor crssubtype' > .ColumnCount = 1 >ENDWITH >>
>*Combo1 interactive change event >with thisform.Grid1 > .recordsource=.recordsource > .refresh() >ENDWITH > >With This.Parent.combo2 > .Requery() > .ListIndex=0 > ENDWITH > >>