用窗口可以:
If Forms("窗口1").opened Then
Dim t1 As Table=Tables("窗口1_Table1")
Dim ID As Integer = e.Table.Current("Code")
Dim sql,Lms,s1 As String
If id >0 Then
Lms =DataTables("工序明细").GetComboListString("WOrderName","MainCode =" & Id,"_sortKey")
For Each s1 In Lms.split("|")
sql+=",Sum(iif(WOrderName ='" & s1 & "',FinishAmount,0)) As " & s1
Next
sql="Select a.*," & Lms.Replace("|",",") & " From(Select Code As 电脑序号,wupingBM As 物品编码,Finish2 As 订单日期," _
& "amount As 订单数 From{工序单} Where Code = " & ID & ") a INNER Join (Select MainCode " & sql & " From{工序明细} " _
& "Where MainCode = " & Id & " Group By MainCode) b ON a.电脑序号 = b.MainCode"
t1.Fill(sql,"",True)
End If
End If