以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  从dr里找到dr2的行更新数值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=125004)

--  作者:yetle
--  发布时间:2018/9/18 10:40:00
--  从dr里找到dr2的行更新数值
为什么订料数没有发生变化?

If Forms("下采购订单").opened
  Dim dr2 As DataRow
  dr2= DataTables("采购明细表").Find("[采购单号] = \'" & Tables("下采购订单_table1").current("采购单号")  & "\'")
  Dim dr As DataRow
  dr = DataTables("采购需求").Find("[物料基本信息_物料ID] = \'" & dr2("物料基本信息_物料ID")  & "\'")   
        If dr IsNot Nothing Then 
            dr.Locked = False \'解锁行
            dr("订料数") = dr2("订料数")
        End If 
dr.Locked = True \'锁定行
End If

--  作者:有点甜
--  发布时间:2018/9/18 11:13:00
--  

执行下面代码,看弹出的信息是否正确。

 

If Forms("下采购订单").opened
    msgbox(123)
    Dim dr2 As DataRow
    dr2= DataTables("采购明细表").Find("[采购单号] = \'" & Tables("下采购订单_table1").current("采购单号")  & "\'")
    msgbox("[采购单号] = \'" & Tables("下采购订单_table1").current("采购单号")  & "\'")
    Dim dr As DataRow
    dr = DataTables("采购需求").Find("[物料基本信息_物料ID] = \'" & dr2("物料基本信息_物料ID")  & "\'")
    msgbox("[物料基本信息_物料ID] = \'" & dr2("物料基本信息_物料ID")  & "\'")
    If dr IsNot Nothing Then
        msgbox(456)
        dr.Locked = False \'解锁行
        dr("订料数") = dr2("订料数")
    End If
    dr.Locked = True \'锁定行
End If


--  作者:yetle
--  发布时间:2018/9/18 11:24:00
--  
都没错,只是到了这一句:msgbox("[物料基本信息_物料ID] = \'" & dr2("物料基本信息_物料ID")  & "\'"),只弹出了一行的物料ID信息     


[此贴子已经被作者于2018/9/18 11:30:46编辑过]

--  作者:有点甜
--  发布时间:2018/9/18 11:40:00
--  

这个意思?

 

If Forms("下采购订单").opened
    Dim dr2 As DataRow
    dr2= DataTables("采购明细表").Find("[采购单号] = \'" & Tables("下采购订单_table1").current("采购单号")  & "\'")
    For Each dr As DataRow In DataTables("采购需求").Select("[物料基本信息_物料ID] = \'" & dr2("物料基本信息_物料ID")  & "\'")
        msgbox(456)
        dr.Locked = False \'解锁行
        dr("订料数") = dr2("订料数")
        dr.Locked = True \'锁定行
    Next
End If


--  作者:yetle
--  发布时间:2018/9/19 14:48:00
--  
好了,改成两个For Each就行了
[此贴子已经被作者于2018/9/19 14:54:35编辑过]