我是Access的新手并尝试计算数据集中的行数并使用以下代码。我收到一个运行时错误,这似乎是因为SQL语句。我从查询中复制了它,所以我不确定我做错了什么。
Function RecordCount()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sqlstring As String
Dim x As Integer
Dim FindRecordCount As Integer
sqlstring = "SELECT Question_List.Questions, Question_List.[Freq] FROM Question_List WHERE (((Question_List.ClientCd)=`" & [Forms]![TestControlCreate]![ComClient] & "));"
Set db = CurrentDb
Set rst = db.OpenRecordset(sqlstring)
FindRecordCount = rst.RecordCount
Return
End Function
答案 0 :(得分:0)
应该按以下方式重建SqlString:
sqlstring = "SELECT Question_List.[Questions], Question_List.[Freq] FROM Question_List WHERE Question_List.[ClientCd]= '" & [Forms].[TestControlCreate].[ComClient] & "';"