以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代码 在数据表中自动取上一行的某一列值  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=8264)

--  作者:卟离卟弃
--  发布时间:2010/9/25 16:52:00
--  代码 在数据表中自动取上一行的某一列值

各位老师,有一疑问需要各位解决一下.

 

表中代码

Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
    Case "物料编码"
        If  dr.IsNull("物料编码") = False Then
            Dim dr1,dr2 As DataRow
            dr1 = DataTables("表A").Find("[物料编码] = \'" & e.DataRow("物料编码") & "\' and [_Identify] <  \'" & e.DataRow("_Identify") & "\'")
            If dr1 IsNot Nothing Then
                dr("库存") = dr1("出货后库存")
            End If
        Else
            dr("库存") = Nothing
        End If
End Select

 

我的想法是,根据  物料编码,自动取上一个物料编码的  出货后库存 值..

 

现在问题是:某一物料编码再表中出现多次,,,,而后面出现的时候,,dr("库存") = dr1("出货后库存")  得到的值都是第一次

的 dr1("出货后库存")  ; 并不是前一次出货后所得到的库存数

 

 

 

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:自动取上一行的值.zip


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

--  作者:blackzhu
--  发布时间:2010/9/25 17:17:00
--  
看狐爸的流水账示例嘛
--  作者:狐狸爸爸
--  发布时间:2010/9/25 17:20:00
--  
你要的不是第一个,而是倒数第一个,Find的帮助其实对此有说明的:
 
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
    Case "物料编码"
        If  dr.IsNull("物料编码") = False Then
            Dim dr1,dr2 As DataRow
            dr1 = DataTables("表A").Find("[物料编码] = \'" & e.DataRow("物料编码") & "\' and [_Identify] <  \'" & e.DataRow("_Identify") & "\'", "[_Identify] Desc")
            If dr1 IsNot Nothing Then
                dr("库存") = dr1("出货后库存")
            End If
        Else
            dr("库存") = Nothing
        End If
End Select

--  作者:卟离卟弃
--  发布时间:2010/9/25 17:44:00
--  

谢谢,后来才想起  Desc 这个功能..