以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于自动找到空行填写填规定值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=132901)

--  作者:bashanren
--  发布时间:2019/4/1 20:46:00
--  关于自动找到空行填写填规定值

老师们晚上辛苦!!!

下面这段代码,是在B表中输入值后,在A表中的C列找该值,如果没找到,则在C列中找到第一个空值的单元格,并填写该值,如果找不到空值的行,则添加一行后再填写。可我下面的代码总是有错,请老师帮忙,谢谢老师们:

Select Case e.DataCol.name
    Case "发文单位"

       \' Dim dr As DataRow = DataTables("词典").Find("发文单位 = \'" & e.OldValue & "\'")
 Dim dr As DataRow = DataTables("词典").Find("发文单位 = \'" & e.newValue & "\'")
        If dr Is Nothing Then
Dim Row As DataRow = DataTables("词典").find("发文单位 = Nothing ,Index") \'-------找到"发文单位"第一个为空值的行
If Row = True Then                          \'---------------如果找到空值的第一行
 dr("发文单位") = e.DataRow("发文单位")
Else
            dr = DataTables("词典").AddNew() \'-------------如果无空值的行,则添加一行
            dr("发文单位") = e.DataRow("发文单位")
End If
        End If
End Select

[此贴子已经被作者于2019/4/1 20:52:23编辑过]

--  作者:有点蓝
--  发布时间:2019/4/1 21:03:00
--  
先好好看看:http://www.foxtable.com/webhelp/scr/0396.htm
--  作者:有点蓝
--  发布时间:2019/4/1 21:06:00
--  
Select Case e.DataCol.name
    Case "发文单位"
        If e.newValue > "" Then
            Dim dr As DataRow = DataTables("词典").Find("发文单位 = \'" & e.newValue & "\'")
            If dr Is Nothing Then
                dr = DataTables("词典").Find("发文单位 is null") \'-------找到"发文单位"第一个为空值的行
                If dr Is Nothing  Then                          \'---------------如果找到空值的第一行
                    dr = DataTables("词典").AddNew()
                End If
                dr("发文单位") = e.newValue
            End If
        End If
End Select