表中有这样一个字段“类别",他的可能值为多个:学生,老师,工人
也可能为一个值比如:老师
现在a='学生'为什么一下查询为0?应该怎么写?
sql="select * from table where 类别 like '" & a & "'"
data1.recordsource=sql
data1.refresh
但是结果是0条记录。
也可能为一个值比如:老师
现在a='学生'为什么一下查询为0?应该怎么写?
sql="select * from table where 类别 like '" & a & "'"
data1.recordsource=sql
data1.refresh
但是结果是0条记录。
like的用法好像是 like '%"& a &"%'
我感觉你的like用法不对如果直接用 where 类别 = '" & a & "'"
有数据吗
msg="类别 like '" & msg & "'“
data1.recordset.findfirst msg
if data1.recordset.nomatch then
msgbox"no record"
end if
data1.recordsource=sql
data1.refresh
先这样查询如果有记录