难道都要用 if text1.text <>'' zhen sql语句 = “and 手机号码 = ' & 手机号码那个格子里的内容 & '” end if???这样 都要用if 来筛选 程序不是很冗长嘛
dim strsql as string dim strwhere1 as string dim strwhere2 as string dim strwhere3 as stringif text1.text="" then strwhere1="" else strwhere1=" and a='"& text1.text &"'" end if if text2.text="" then strwhere2="" else strwhere2=" and b='"& text2.text &"'" end if if text3.text="" then strwhere3="" else strwhere3=" and c='"& text3.text &"'" end ifstrsql=" select * from tablename where 1=1 " & strwhere1 & strwhere2 & strwhere3
有29个 text 7个 combo 还有6个check
用控件数组+FOR循环 设置相同的默认值,以便判断
dim a(28) as String '想办法把字段的名字存到这个数组
S="Select * From TABL1 Where " For i = 0 To 28 if Text1(i).Text<>"" Then S=S & " And " & a(i) & " = '" & Text1(i).Text & "'" Endif next i
zhen sql语句 = “and 手机号码 = ' & 手机号码那个格子里的内容 & '”
end if???这样 都要用if 来筛选 程序不是很冗长嘛
dim strwhere1 as string
dim strwhere2 as string
dim strwhere3 as stringif text1.text="" then
strwhere1=""
else
strwhere1=" and a='"& text1.text &"'"
end if
if text2.text="" then
strwhere2=""
else
strwhere2=" and b='"& text2.text &"'"
end if
if text3.text="" then
strwhere3=""
else
strwhere3=" and c='"& text3.text &"'"
end ifstrsql=" select * from tablename where 1=1 " & strwhere1 & strwhere2 & strwhere3
有29个 text 7个 combo 还有6个check
设置相同的默认值,以便判断
'想办法把字段的名字存到这个数组
S="Select * From TABL1 Where "
For i = 0 To 28
if Text1(i).Text<>"" Then
S=S & " And " & a(i) & " = '" & Text1(i).Text & "'"
Endif
next i
在SQL里用 strx(N) & strx(N)