我有两个相互关联的表:QUOTERun
和QUOTERunResults
. QUOTERun
包含特定报价所需的所有项目。 QUOTERunResults
包含所有供应商响应的记录。我有一个程序可以分析这些响应并选择最合适的供应商并将一个名为Preffered
true 的字段设置为。有时没有一个供应商会工作。我需要创建一个所有记录的列表,QUOTERun
其中没有QUOTERunResults
标记为首选的匹配记录。
这是我到目前为止所拥有的:
Set rs1 = CurrentDb.OpenRecordset("SELECT ReferenceNumber FROM [QUOTERun] WHERE RunID = " & TempRunID, dbOpenDynaset)
Set rs2 = CurrentDb.OpenRecordset("SELECT ReferenceNumber, Preffered FROM [QUOTERunResults] " & _
"WHERE RunID = " & TempRunID & " AND Preffered = True", dbOpenDynaset)
If (rs2.RecordCount = 0) Then
TempListNotComplete = "NONE OF THE VENDOR RESPONSES HAD ENOUGH STOCK. NO RECORDS HAVE BEEN MARKED AS PREFFERED."
ElseIf (rs1.RecordCount <> 0) Then
rs1.MoveFirst
Do While rs1.EOF <> True
rs2.FindFirst "ReferenceNumber = " & rs1.Fields("[ReferenceNumber]").value
If (rs2.Fields("[ReferenceNumber]").value <> rs1.Fields("[ReferenceNumber]").value) Then
If (TempListNotComplete = "") Then
TempListNotComplete = rs1.Fields("[ReferenceNumber]").value
Else
TempListNotComplete = TempListNotComplete & ", " & rs1.Fields("[ReferenceNumber]").value
End If
End If
rs1.MoveNext
Loop
End If
有没有更有效的方法来做上述事情?