出现以下错误.... <作为查询参数输入的表达式产生了这个错误:'rs!StoreID'>
rs!StoreID 是 Stores 表中的一个整数,在 msgbox 函数中打印得很好我做错了什么?我以前用过 Dcount 很多次,只是没有循环遍历表中的记录......
谢谢!
strSQL = "SELECT * FROM Stores"
Set rs = CurrentDb.OpenRecordset(strSQL)
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
While (Not rs.EOF)
MsgBox ("Store: " & rs!StoreID & ", Name: " & rs!FullStoreName)
'Make sure data exists for Store in AccountBalances Table for start and end dates
If ((DCount("*", "AccountBalances", "[RecDate] = TempVars!varDate And [StoreID] = rs!StoreID") <= 0) Or _
(DCount("*", "AccountBalances", "[RecDate] = TempVars!varStartDate And [StoreID] = rs!StoreID") <= 0)) Then
NoData = NoData + 1
NoDataStoreList = NoDataStoreList & rs!FullStoreName & vbCrLf
End If
MsgBox ("Checking for CFS Orphans")
'Check if any Account Numbers for selected Store have Unassigned CFS Line Item in the AccountNumbers Table
NumRecs = DCount("*", "AccountNumbers", "[StoreID] = rs!StoreID And [CFS LineItem] = 0 And [Account Type] = '2-Assets'") _
+ DCount("*", "AccountNumbers", "[StoreID] = rs!StoreID And [CFS LineItem] = 0 And [Account Type] = '3-Liability'") _
+ DCount("*", "AccountNumbers", "[StoreID] = rs!StoreID And [CFS LineItem] = 0 And [Account Type] = '4-Net Worth'")
If (NumRecs > 0) Then
CFSOrphans = CFSOrphans + 1
CFSOrphansStoreList = CFSOrphansStoreList & rs!FullStoreName & " - " & NumRecs & " Accounts" & vbCrLf
End If
rs.MoveNext
Wend
End If
rs.Close
Set rs = Nothing