我没有得到正确的 DCount 值
表是“课程”:
ID(自动)pk
InstructorID As Integer
Weekof As Date
StudentID As Integer
Status As Byte
我的功能是
Public Function NoRecordsFound(ByVal instructorid As Integer, ByVal weekof As Date, studentid As Integer) As Integer
Dim strCriteria As String
strCriteria = "Lessons.[InstructorID] = " & instructorid & " AND Lessons.[WeekOf] = " & weekof & " AND Lessons.[StudentID] = " & studentid
NoRecordsFound = DCount("*", "Lessons", strCriteria)
End Function
该函数从即时窗口调用为:
:Debug.Print(NoRecordsFound(5, DateValue("10/3/2016"), 17043))
以下 select 语句确实返回了正确的记录数(应该是 1):
SELECT Lessons.[ID], Lessons.[InstructorID], Lessons.[WeekOf], Lessons.[StudentID], Lessons.[Status]
FROM Lessons
WHERE (((Lessons.[InstructorID])=5) AND ((Lessons.[WeekOf])=DateValue("10/3/2016")) AND ((Lessons.[StudentID])=17043));
有人可以帮助发现我的 DCount 表达式中的错误吗?