以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  发现一错误提示,不明原因  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=25350)

--  作者:yankunhao
--  发布时间:2012/11/7 9:08:00
--  发现一错误提示,不明原因


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

 

代码如下:

 

 

Dim tbl As Table = Tables("自动录入_Table1")
If e.KeyCode = Keys.Up Then
    tbl.Position = tbl.Position - 1
    e.Cancel = True
ElseIf e.KeyCode = Keys.Down Then
    tbl.Position = tbl.Position + 1
    e.Cancel = True
ElseIf e.KeyCode = Keys.Enter Then
    If tbl.Current IsNot Nothing Then
        If e.Control = False Then
           \' Select Case "obas_part_spec"
                \'Case "obas_part_spec"
                    For Each dr1 As DataRow In DataTables("授权表").Select("用户名 = \'" & Vars("_UserName") & "\'" )
                        If dr1("表名") = Tables("obas_part_spec").Name AndAlso dr1("只能编辑个人数据")=True Then
                            If Vars("_UserName") <> Tables("obas_part_spec").Current("user_no") Then
                                Messagebox.Show("你已经被限制只能编缉属于你自己的数据!,如有疑问,请与管理员联系","提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                Dim r2 As Row  = Tables("obas_part_spec").AddNew()
                                 Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no")

                                \'Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码
                                \'Tables("obas_part_spec").Current("料品名称") = tbl.Current("料品名称")
                                \'Tables("obas_part_spec").Current("料品规格") = tbl.Current("料品规格")
                                \'Tables("obas_part_spec").Current("料品归类") = tbl.Current("料品归类")
                                \'Tables("obas_part_spec").Current("库存单位") = tbl.Current("库存单位")
                              

                            End If
                        End If
                         If dr1("表名") = Tables("obas_part_spec").Name AndAlso dr1("只能编辑部门数据")=True Then
                           If Tables("obas_part_spec").Current.isnull("部门") Then
                                Return
                               
                            ElseIf dr1("部门范围").indexof( Tables("obas_part_spec").Current("部门")) < 0 Then
                               
                                Messagebox.Show("你已经被限制只能编缉属于你的部门数据!,如有疑问,请与管理员联系","提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                 Tables("obas_part_spec").AddNew()
                                 Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no")

                                \'Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码
                                \'Tables("obas_part_spec").Current("料品名称") = tbl.Current("料品名称")
                                \'Tables("obas_part_spec").Current("料品规格") = tbl.Current("料品规格")
                                \'Tables("obas_part_spec").Current("料品归类") = tbl.Current("料品归类")
                                \'Tables("obas_part_spec").Current("库存单位") = tbl.Current("库存单位")                               
                            End If
                        End If
                         If dr1("表名") = Tables("obas_part_spec").Name AndAlso dr1("只能编辑组数据")=True Then
                           If Tables("obas_part_spec").Current.isnull("org_no") Then
                                Return
                               
                            ElseIf dr1("可编辑组范围").indexof( Tables("obas_part_spec").Current("org_no")) < 0 Then
                               
                                Messagebox.Show("你已经被限制只能编缉属于你组名数据!,如有疑问,请与管理员联系","提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                Tables("obas_part_spec").AddNew()
                                Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码

                                \'Dim r2 As Row  = Tables("obas_part_spec").AddNew()
                                \'r2("part_no") ="123456"
                                \'tbl.Current("part_no")

                                \'Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码
                                \'Tables("obas_part_spec").Current("料品名称") = tbl.Current("料品名称")
                                \'Tables("obas_part_spec").Current("料品规格") = tbl.Current("料品规格")
                                \'Tables("obas_part_spec").Current("料品归类") = tbl.Current("料品归类")
                                \'Tables("obas_part_spec").Current("库存单位") = tbl.Current("库存单位")                               
                            End If
                        End If
                    Next
            \'End Select
        Else
            For Each r1 As Row In Tables("自动录入_Table1").GetCheckedRows
                Dim r2 As Row  = Tables("obas_part_spec").AddNew()
                r2("part_no") = r1("part_no")
                \'r2("料品名称") = r1("料品名称")
                \'r2("料品归类") = r1("料品归类")
                \'r2("料品规格") = r1("料品规格")
                \'r2("库存单位") = r1("库存单位")
            Next
           
        End If
    End If
    e.Cancel = True
   e.Form.Close()
End If
If e.KeyCode = Keys.Escape
    e.Form.Close()
End If


--  作者:yankunhao
--  发布时间:2012/11/7 9:10:00
--  
请问这是什么原因呢?
--  作者:lin_hailun
--  发布时间:2012/11/7 9:19:00
--  
 楼主,你可以自己确定一下哪一行出错了。在代码里加入多个Msgbox(),大概就能确定哪里出错。

http://www.foxtable.com/help/topics/1485.htm

--  作者:yankunhao
--  发布时间:2012/11/7 9:26:00
--  

问题是我增加其它产品的时候没这个错,现发现有几个产品是这样的


--  作者:lin_hailun
--  发布时间:2012/11/7 9:44:00
--  
 楼主,你可以加一两个msgbox先定位一下错误……因为我也不清楚哪里出错了。

 这样可以缩小大家排错的范围。

--  作者:yankunhao
--  发布时间:2012/11/7 9:47:00
--  

ElseIf dr1("可编辑组范围").indexof( Tables("obas_part_spec").Current("org_no")) < 0 Then
                               
                                Messagebox.Show("你已经被限制只能编缉属于你组名数据!,如有疑问,请与管理员联系","提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                Tables("obas_part_spec").AddNew()
                                Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码 

 

 

将上面的代码"Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码 " 改为下面这样的,就没出错,我想就是这一行代码有问题,但我不明原因,因为其它产品是没问题的.

 

Tables("obas_part_spec").Current("part_no") = "O0000000000000023674" \'单行写入的代码


--  作者:yankunhao
--  发布时间:2012/11/7 9:49:00
--  
且我检查过 tbl.Current("part_no") 是有数据的啊
--  作者:yankunhao
--  发布时间:2012/11/7 10:05:00
--  

将代码改成下面这样的,可以显示到 tbl.Current("part_no") 的值的,请问有谁能说一下原因吗?

 

ElseIf dr1("可编辑组范围").indexof( Tables("obas_part_spec").Current("org_no")) < 0 Then
                               
                                Messagebox.Show("你已经被限制只能编缉属于你组名数据!,如有疑问,请与管理员联系","提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Else
                                Dim s As String =tbl.Current("part_no")
                                  MessageBox.Show(s)

                                \'Tables("obas_part_spec").AddNew()
                                \'Tables("obas_part_spec").Current("part_no") = tbl.Current("part_no") \'单行写入的代码


--  作者:lin_hailun
--  发布时间:2012/11/7 10:17:00
--  
 楼主,我看了一整天,确实不知道是哪句代码错了……

 远程看一下,加QQ800014337

--  作者:yankunhao
--  发布时间:2012/11/7 10:19:00
--  

我将将码改一下,可以了,但还是想不明白原因啊!

改成这样的:

Tables("obas_part_spec").AddNew()

Dim s As String =tbl.Current("part_no")

Tables("obas_part_spec").Current("part_no") = s

 

有谁能解答一下吗? 这样有何分别?

[此贴子已经被作者于2012-11-7 10:20:29编辑过]