VBA / ACCESS EASY:查询表中的是/否字段

时间:2014-12-02 18:05:12

标签: vba access-vba ms-access-2007

寻找vba代码的查询语法,以便查找是/否字段=否。

 Set rsStepCalendar = db.OpenRecordset("Select * from tblStepCalendar" & _
                                            "Where (groupNr like '*" & txtGroupNum.Value & "*' )" & _
                                            "AND (CanceledContact = 0)", dbOpenDynaset)

1 个答案:

答案 0 :(得分:2)

如果您的SQL语句准确无误,则以下内容应该有效。

Dim strSQL AS String
Dim db AS DAO.Database
Dim rsStepCalendar AS DAO.Recordset

strSQL = "SELECT" & VbCrLf & _
         "    S.*" & VbCrLf & _
         "FROM tblStepCalendar S" & VbCrLf & _
         "WHERE S.groupNr LIKE '*" &  txtGroupNum.Value & "*'" & VbCrLf & _
         "AND S.CanceledContact = 0"

Set db = CurrentDB
Set rsStepCalendar = db.OpenRecordset(strSQL, dbOpenDynaset)