以文本方式查看主题

-  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=2716)

--  作者:程兴刚
--  发布时间:2009/5/8 13:01:00
--  [求助] 这段代码为什么通不过,
DataColChanged事件代码:

 

If e.DataCol.Name = "上级项目名称" Then

   Dim dr As DataRow

   dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'","编号 Desc")

   if dr.IsNull("项目名称")  Then

      e.datarow("选择标记") = false

   else

      e.datarow("选择标记") = true

   end if

end if



去掉这个判断可以(也就是这一段为何通不过?):

   if dr.IsNull("项目名称")  Then

     

献丑!


--  作者:狐哥
--  发布时间:2009/5/8 13:15:00
--  
看好多老师在isnull()后面加个指定判断,不知是不是这样.
if
dr.IsNull("项目名称") = true then

还有DR如找不到是不是也要出错,是否也要加个dr isnot nothing 的判断
[此贴子已经被作者于2009-5-8 13:20:09编辑过]

--  作者:yangming
--  发布时间:2009/5/8 13:16:00
--  

多分支形式:

If 条件1 Then
    代码1

ElseIf
条件2 Then
    代码2

ElseIf
条件3 Then
    代码3

    .....
Else

    代码X

End If


--  作者:八婺
--  发布时间:2009/5/8 13:26:00
--  
If e.DataCol.Name = "上级项目名称" Then
    Dim dr As DataRow
    dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'","编号 Desc")
    If dr Is Nothing Then
        e.datarow("选择标记") = false
    else
        e.datarow("选择标记") = true
    end if
end if
[此贴子已经被作者于2009-5-8 13:26:56编辑过]

--  作者:cpayinyuan
--  发布时间:2009/5/8 13:32:00
--  

少了个 if dr isnot nothing的判断,你只判断dr("项目名称")是否为空,没有考虑dr也可能为空。

补充:4楼的代码好像不太准确,dr是nothing,与dr("项目名称")为空是两回事,直接代替不太合适。

If e.DataCol.Name = "上级项目名称" Then

   Dim dr As DataRow

   dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'","编号 Desc")

  if dr isnot nothing
  
if dr.IsNull("项目名称")  Then

      e.datarow("选择标记") = false

   else

      e.datarow("选择标记") = true

   end if
  
end if
end if

[此贴子已经被作者于2009-5-8 13:36:35编辑过]

--  作者:fm962
--  发布时间:2009/5/8 14:25:00
--  
 

If e.DataCol.Name = "上级项目名称" Then

   Dim dr As DataRow

   dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'","编号 Desc")

  

elseif dr.IsNull("项目名称")  Then


      e.datarow("选择标记") = false

   else

      e.datarow("选择标记") = true

   end if


我认为这样就行了


--  作者:狐狸爸爸
--  发布时间:2009/5/8 14:30:00
--  

上午8:58分,我在群里就回了的,老程居然只管提问,不看回复。

图片点击可在新窗口打开查看


金亿通(475361999) 08:57:25
但是运行时这个代码出错:
If e.DataCol.Name = "上级项目名称" Then
  Dim dr As DataRow
  dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'")
  if dr.IsNull("项目名称") then
     e.datarow("选择标记") = False
  else
     e.datarow("选择标记") = true
  end if
end if

贺老六(84069599) 08:58:38
If e.DataCol.Name = "上级项目名称" Then
  Dim dr As DataRow
  dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'")
  If dr isnot Nothing Then
     if dr.IsNull("项目名称") then
         e.datarow("选择标记") = False
     else
        e.datarow("选择标记") = true
     end if
   End If
end if

[此贴子已经被作者于2009-5-8 14:48:13编辑过]

--  作者:狐狸爸爸
--  发布时间:2009/5/8 14:35:00
--  
可能这样合适点:

If e.DataCol.Name = "上级项目名称" Then
    Dim dr As DataRow
    dr = DataTables("项目明细").Find("[工程序号] = \'" & Tables("项目信息").Current("序号") & "\' and [项目名称] = \'" & e.datarow("项目名称") & "\'")
    If dr isNot Nothing AndAlso dr.IsNull("项目名称") then
        e.datarow("选择标记") = False
    Else
        e.datarow("选择标记") = true
    End If
end if

--  作者:yangming
--  发布时间:2009/5/8 14:37:00
--  
还是在论坛提问好,大家都学学,呵
--  作者:程兴刚
--  发布时间:2009/5/8 16:54:00
--  

谢谢,还是不能实现,

我需要达到的目的是切换父表的记录,自动将项目选择表的选择标记勾选,勾选条件是当前表的项目在项目明细表已经存在,项目明细表的记录且属于与项目信息表(父表)的当前记录相关联的记录。

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:szsj.rar