所以这是我第一次与工会合作,我正在尝试查询 3 个表。
抽象的
我正在尝试从具有相同 ID 的 3 个不同表(每个表一个字段)中选择 3 个字段。
我希望每组记录都有来自 3 个字段的结果,然后我可以使用 3 个结果。似乎正在发生的事情是它获取所有结果并为每个结果创建一个记录集
任何指导将不胜感激,据我所知,我可能会以完全错误的方式解决这个问题。
这是我正在使用的代码
Dim rs1 As DAO.Recordset
Dim unionquery As String
unionquery = "select
[Test Script] from TEST_SCRIPTS where TEST_ID= " & Me.TEST_ID & "
union select
PROC_ID from PROC_CHECK where TEST_ID= " & Me.TEST_ID & "
union select all
[Software Version] from SOFTWARE_VERSION where TEST_ID= " &
Me.TEST_ID & " "
Set rs1 = CurrentDb.OpenRecordset(unionquery, dbOpenForwardOnly)
If Not (rs1.EOF And rs1.BOF) Then
Do Until rs1.EOF = True
' I THOUGHT THIS WOULD WORK BUT I GET AN ERROR SAYING rs1!PROC_ID AND
' rs1![Software Version] are not part of the recordset
' WHEN I ALERT OUT rs1![Test Script] i get the whole set
MsgBox " " & rs1![Test Script] & ", " & rs1!PROC_ID & ", "
& rs1![Software Version] & " "
Loop
End If
rs1.Close
Set rs1 = Nothing