以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  表A选中的值,在表B中自动选中。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=143286)

--  作者:keli0917
--  发布时间:2019/11/19 17:44:00
--  表A选中的值,在表B中自动选中。

同一个窗口中有两个TABLE1,TABLE2。TABLE1和TABLE2中有一个相同的关键列,列名为A。

在Table1中选定某一行,Checked值设为真的时候,自动从TABLE2中选中A列值相同的行,也把Checked值设为真。下面的代码只能选中TABLE2中的一行,有多个行满足条件的时候,不能全部选中。帮忙修改代码

 

Dim dr As Row =Tables(e.form.name & "_table1").Current
If dr.Checked  =True Then
    dr.Checked  =False
Else
    dr.Checked  =True
End If

 

Dim tb2 As Table =Tables(e.form.name & "_table2")
With tb2
     Dim r As Integer
     r = .Find(dr("A"), .RowSel + 1, "工作号", False, False, True)
    If r > - 1 Then \'如果找到符合条件的行
          .rows(r).Checked  = dr.Checked
    End  If
 End With

[此贴子已经被作者于2019/11/19 18:00:17编辑过]

--  作者:keli0917
--  发布时间:2019/11/19 18:01:00
--  

已成功。谢谢。

Dim dr As Row =CurrentTable.Current
If dr.Checked  =True Then
    dr.Checked  =False
Else
    dr.Checked  =True
End If
  Dim tb2 As Table =Tables(e.form.name & "_table2")

For Each r2 As Row In tb2.Rows
      With tb2
       
        If r2("A") = dr("A") Then \'如果找到符合条件的行
            r2.Checked  = dr.Checked
        End  If
    End With
Next