以文本方式查看主题

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

--  作者:菜鸟飞
--  发布时间:2015/4/27 22:42:00
--  美化自动编号代码,出现调用目标异常
调用的目标发生了异常。
未将对象引用设置到对象的实例。

不知道怎么解决这个错误,一个人运行正常,换个人出现对象引用错误

这是代码:
Select e.DataCol.Name
    Case "出库人","出库时间"
        If e.DataRow.IsNull("出库时间") OrElse e.DataRow.IsNull("出库人") Then
            e.DataRow("出库编号") = Nothing
        Else
            Dim d As Date = e.DataRow("出库时间")
            Dim y As Integer = d.Year
            Dim m As Integer = d.Month
            Dim Days As Integer = Date.DaysInMonth(y,m)
            Dim fd As Date = New Date(y,m,1) \'获得该月的第一天
            Dim ld As Date = New Date(y,m,Days) \'获得该月的最后一天
            Dim bh As String = e.DataRow("出库人") & "-" & Format(d,"yyyyMM") & "-" \'生成编号的前缀
            If e.DataRow("出库编号").StartsWith(bh) = False \'如果出库编号前缀不符
                Dim max As String
                Dim idx As Integer
                Dim flt As String
                Dim lh As Integer
                flt = "出库人 = \'"& e.DataRow("出库人") & "\' And 出库时间 >= #" & fd & "# And 出库时间 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
                max = e.DataTable.Compute("Max(出库编号)",flt) \'取得该月的相同出库人的最大出库编号
                lh = max.Length-4 \'获取字符串的长度\'
                If max > "" Then \'如果存在最大出库编号
                    idx = CInt(max.SubString(lh,4)) + 1 \'获得最大出库编号的后四位顺序号,并加1
                Output.Show(lh)
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("出库编号") = bh & Format(idx,"0000")
            End If
        End If
End Select

--  作者:Bin
--  发布时间:2015/4/28 8:47:00
--  
建议您用这个方法:
http://www.foxtable.com/help/topics/1485.htm

先找出是哪一行出错,然后分析原因,搞不定,可以在论坛发帖,贴出代码,并告诉我们运行到哪一行出错,以及错误提示。