所以我有以下......
Sub test4()
Dim db As DAO.Database
Dim Source_rst As DAO.Recordset
Dim Dest_rst As DAO.Recordset
Set db = CurrentDb
Set Source_rst = db.OpenRecordset("SELECT DISTINCTROW [Scorecard Last Ran].[Scorecard ID], Round(([DQS - Scorecard History].[No Passed]/([DQS - Scorecard History].[No Passed]+[DQS - Scorecard History].[No Failed]))*100,1) & '%' AS Score FROM [DQS - Scorecards] INNER JOIN ((SELECT [DQS - Scorecard History].[Scorecard ID], Max([DQS - Scorecard History].[Date/Time Scorecard Ran]) AS [MaxOfDate/Time Scorecard Ran] FROM [DQS - Scorecard History] GROUP BY [DQS - Scorecard History].[Scorecard ID]) AS [Scorecard Last Ran] INNER JOIN [DQS - Scorecard History] ON ([Scorecard Last Ran].[MaxOfDate/Time Scorecard Ran] = [DQS - Scorecard History].[Date/Time Scorecard Ran]) AND ([Scorecard Last Ran].[Scorecard ID] = [DQS - Scorecard History].[Scorecard ID])) ON [DQS - Scorecards].ID = [DQS - Scorecard History].[Scorecard ID];")
Set Dest_rst = db.OpenRecordset("DQS - Scorecards")
If (Source_rst.BOF And Source_rst.EOF) Or (Dest_rst.BOF And Dest_rst.EOF) Then Exit Sub
While (Not Source_rst.EOF)
Dest_rst.MoveFirst
While (Not Dest_rst.EOF)
If Dest_rst![ID] = Source_rst![Scorecard ID] And Dest_rst![ID] <> 3 Then
Debug.Print Source_rst![Scorecard ID] & " - " & Source_rst![Score]
Dest_rst.Edit
Dest_rst![Score] = Source_rst![Score]
Dest_rst.Update
DoEvents
End If
Dest_rst.MoveNext
Wend
Source_rst.MoveNext
Wend
End Sub
相当直白吧?除非我删除Dest_rst![ID] <> 3
它挂起,即使我离开它几个小时。记录3没有什么特别之处,进入的数据是相同的,格式化为字符串的百分比。如果我排除此记录,效果会非常好。
我知道UPDATE查询会更有效但是也会挂起。我遗失的任何东西?!
Dest_rst是一个非常小的SharePoint列表。
答案 0 :(得分:0)
原来我的SharePoint列表只是一个屁股。从我的数据库中完全删除了列表,重新添加它,一切都很好,恢复了理智!