Foxtable(狐表)用户栏目专家坐堂 → [求助]主从表关联查询问题


  共有4161人关注过本帖树形打印复制链接

主题:[求助]主从表关联查询问题

帅哥哟,离线,有人找我吗?
狐狸爸爸
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47479 积分:251266 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/12/31 8:06:00 [显示全部帖子]

这个没有理由不可以的哦,从表1的DatacolChanged事件:

 

If e.DataCol.name = "姓名" Then
    Dim dr1 As DataRow
    Dim dr2 As DataRow
    Dim dr3 As DataRow
    dr1 = DataTables("主表1").Find("id1 = '" & e.DataRow("id1") & "'")
    If dr1 IsNot Nothing Then
        Dim y As Integer = e.DataRow("年份")
        Dim m As Integer = e.DataRow("月份")
        If m =1 Then
            y = y -1
            m = 12
        Else
            m = m -1
        End If
        dr2 = DataTables("主表2").Find("姓名 = '" & e.DataRow("姓名") & "' And 年份 = " & y & " and 月份 = " & m)
        If dr2 IsNot Nothing Then
            dr3 = DataTables("从表2").Find("id2 = '" & dr2("id2") & "'")
            If dr3 IsNot Nothing Then
                e.DataRow("上月出勤天数") = dr3("出勤数")
            End If
        End If
    End If
End If

 

 


 回到顶部