|
30金钱
现需要窗体上以文本框内容为条件做查询,生成一个记录集,但查询条件为空时视为全部*,此时这个*符号该怎么写?
Private Sub Qry_Click
dim rs as ADODB.Recordset
dim sql as String
sql = "select * from [BM] where [BM].[Operator] like '" & IIF(IsNull(Me.Operator),"*",Me.Operator) & "' "
...
按上述 IIF(IsNull(Me.Operator),"*",Me.Operator) 这样的写法记录集为空,但显然不对
按 IIF(IsNull(Me.Operator),*,Me.Operator) 或 IIF(IsNull(Me.Operator),'*',Me.Operator) 这样又会报错
问题应该比较基础,但让我很纠结
|
最佳答案
查看完整内容
If IsNull(Me.Operator) then
sql = "select * from where .[Operator] like '*" & Me.Operator & "*' "
end if
|