1
,我没有得到正确的价值DCOUNTDCOUNT在Access
表是 “教训” 没有找到符合条件的记录:
ID(自动)PK
InstructorID作为整数
Weekof截止日期
StudentID作为整数
地位字节
我的F油膏是
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表达式中的错误吗?
我看到了在一些例子中,#分隔符,但无法找到它的任何文档。应该追求。非常感谢。 – user2978241