做的一个表单搜索界面,要求两个搜索条件,如何实现两个搜索条件都用上,现在情况是两个条件我选一个就行,另一个没用上
搜索界面.zip
(4.29 KB)
SELECT DISTINCT 岩石名称 FROM 洼里 INTO CURSOR curTmp WITH .RowSourceType = 0 .RowSource = '' .AddItem('(全部)') .AddItem('\-') SCAN .AddItem(TRIM(岩石名称)) ENDSCAN .ListIndex = 1 ENDWITH SELECT DISTINCT 采样地点 FROM 洼里 INTO CURSOR curTmp WITH .RowSource = '' .RowSourceType = 0 .AddItem('(全部)') .AddItem('\-') SCAN .AddItem(TRIM(采样地点)) ENDSCAN .ListIndex = 1 ENDWITH2. 为表单新建一个自定义方法 SetFor,并在方法中输入如下代码:
LOCAL cName,cPlace,cFor cName = = = '' IF cName # '(全部)' cFor = '岩石名称 = ['+cName +']' ENDIF IF cPlace # '(全部)' cFor = cFor + IIF(EMPTY(cFor),'',' AND ')+'采样地点 = ['+cPlace +']' ENDIF SELECT 洼里 SET FILTER TO &cFor GO TOP THISFORM.Refresh3. 将 Combo1 和 Combo2 的 InteractiveChange 事件代码均修改为: THISFORM.SetFor