以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 调用的目标发生了异常 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=126374) |
-- 作者:lxmoffice -- 发布时间:2018/10/19 16:29:00 -- 调用的目标发生了异常 .NET Framework 版本:2.0.50727.8936 Foxtable 版本:2018.3.9.1 错误所在事件:表,生产清单, DataColChanged 详细错误信息: 调用的目标发生了异常。 在 Range 对象中,Min (4547)必须小于或等于 max (-1)。 请问这个是什么错误啊, 如何解决?
|
-- 作者:有点蓝 -- 发布时间:2018/10/19 16:34:00 -- 贴出【表,生产清单, DataColChanged】具体代码看看 |
-- 作者:lxmoffice -- 发布时间:2018/10/19 16:41:00 -- \'日期转换 If e.DataCol.Name = "日期" Then Dim ys As String ys=e.DataRow("日期").year e.DataRow("年份")=ys Dim mh As String mh=e.DataRow("日期").month e.DataRow("月份")=mh If e.DataRow.IsNull("日期") Then e.DataRow("年份")=Nothing e.DataRow("月份")=Nothing End If End If \'============================================================================== \'防止输入相同的零件 Select Case e.DataCol.name Case "生产批次","图纸编号","零件名称" Dim dr As DataRow = e.DataRow If dr.IsNull("生产批次") = False AndAlso dr.IsNull("图纸编号")= False Then \' And dr.IsNull("零件名称") Then If e.DataTable.Compute("Count([_Identify])","生产批次= \'" & dr("生产批次") & "\'And 图纸编号= \'" & dr("图纸编号") & "\' And 零件名称= \'" & dr("零件名称") & "\'") > 1 Then MessageBox.Show("已经存在相同批次相同图编号相同名称的零件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入 End If End If End Select \'--------------------------------------------------------------------------------------------------------------------- \' 当输入时间时, 自动获得零件ID If e.DataCol.Name = "日期" Then If e.DataRow.IsNull("日期") Then e.DataRow("零件ID") = Nothing Else Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("零件ID").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(零件ID)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("零件ID") = bh & "-" & Format(idx,"000") End If End If End If \'----------------------------------------------------------------------------------------------------------------------- |
-- 作者:lxmoffice -- 发布时间:2018/10/19 16:43:00 -- \'----------------------------------------------------------------------------------------------------------------------- \' 当输入入库存日期后, 自动获得相应的工时,成本汇总 If e.DataCol.Name = "入库日期" Then \'If e.DataRow.IsNull("入库日期") Then \' e.DataRow("总工时")= Nothing \' e.DataRow("生产成本")= Nothing \' e.DataRow("入库数量")= Nothing Dim str = User.ExtendedValues("账套") \'msgbox(str) Dim Total11 As Single Dim Total12 As Single Dim Total13 As Single Dim Total14 As Single Dim Total15 As Single Dim Total16 As Single Dim Total17 As Single Dim Total18 As Single Dim Total19 As Single Dim Total110 As Single Dim Total111 As Single Dim Total112 As Single Total11=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=1") e.DataRow("JAN")= Total11 Total12=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=2") e.DataRow("FEB")= Total12 Total13=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=3") e.DataRow("MAR")= Total13 Total14=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=4") e.DataRow("APR")= Total14 Total15=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=5") e.DataRow("MAY")= Total15 Total16=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=6") e.DataRow("JUN")= Total16 Total17=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=7") e.DataRow("JUL")= Total17 Total18=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=8") e.DataRow("AUG")= Total18 Total19=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=9") e.DataRow("SEP")= Total19 Total110=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=10") e.DataRow("OCT")= Total110 Total111=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=11") e.DataRow("NOV")= Total111 Total112=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=12") e.DataRow("DEC")= Total112 \' Else Dim Total1 As Single Dim Total2 As Single Total1=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'") Total2=DataTables("生产记录").Compute("Sum(成本小计)","零件ID= \'"& e.DataRow("零件ID") & "\'") e.DataRow("总工时")= Total1 e.DataRow("生产成本")= Total2 e.DataRow("单位成本")= Total2 / e.DataRow("入库数量") \' End If End If \'------------------------------------------------------------------------------------------------------------------------- \' 自动根据入库日期获得入库月及锁行 If e.DataCol.Name = "入库日期" Then If e.DataRow.IsNull("入库日期") Then e.DataRow("入库月份")= "" e.DataRow.Locked = False Else e.DataRow.Locked = True e.DataRow("入库月份")= e.DataRow("入库日期").year & "-" & e.DataRow("入库日期").month End If End If \'----------------------------------------------------------------------------------------------------------------------- \'材料自动分类 If e.DataCol.Name = "材料名称" Then \'当输入材料名称时 Dim dr As DataRow dr = DataTables("材料细目").Find("材料名称 = \'" & e.DataRow("材料名称") & "\'" ) \'找到对应材料. If dr IsNot Nothing \'如果找到, 则设置各列内容 e.DataRow("材料类别")= dr("材料类别") End If End If
|
-- 作者:有点蓝 -- 发布时间:2018/10/19 16:49:00 -- e.DataRow("单位成本")= Total2 / e.DataRow("入库数量") 改为 if e.DataRow("入库数量") = 0 e.DataRow("单位成本") = 0 else e.DataRow("单位成本")= Total2 / e.DataRow("入库数量") end if 其他地方看不出什么问题,调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看运行到哪一句代码出错
|
-- 作者:lxmoffice -- 发布时间:2018/10/19 17:01:00 -- 老师, 您好! 好像调用<<生产记录>>出现问题, 我把<<生产记录>>删除一些行后, 错误变为 .NET Framework 版本:2.0.50727.8936 Foxtable 版本:2018.3.9.1 错误所在事件:表,生产清单, DataColChanged 详细错误信息: 调用的目标发生了异常。 在 Range 对象中,Min (5212)必须小于或等于 max (-1)。 |
-- 作者:lxmoffice -- 发布时间:2018/10/19 17:10:00 -- 还是找不到原因, 我把以下代码隔开就不报警了, 但看不出代码有什么问题, 是不是调用的表<<生产记录>>存有问题? 请指教 \' 当输入入库存日期后, 自动获得相应的工时,成本汇总 If e.DataCol.Name = "入库日期" Then \'If e.DataRow.IsNull("入库日期") Then \' e.DataRow("总工时")= Nothing \' e.DataRow("生产成本")= Nothing \' e.DataRow("入库数量")= Nothing Dim str = User.ExtendedValues("账套") \'msgbox(str) Dim Total11 As Single Dim Total12 As Single Dim Total13 As Single Dim Total14 As Single Dim Total15 As Single Dim Total16 As Single Dim Total17 As Single Dim Total18 As Single Dim Total19 As Single Dim Total110 As Single Dim Total111 As Single Dim Total112 As Single Total11=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=1") e.DataRow("JAN")= Total11 Total12=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=2") e.DataRow("FEB")= Total12 Total13=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=3") e.DataRow("MAR")= Total13 Total14=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=4") e.DataRow("APR")= Total14 Total15=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=5") e.DataRow("MAY")= Total15 Total16=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=6") e.DataRow("JUN")= Total16 Total17=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=7") e.DataRow("JUL")= Total17 Total18=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=8") e.DataRow("AUG")= Total18 Total19=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=9") e.DataRow("SEP")= Total19 Total110=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=10") e.DataRow("OCT")= Total110 Total111=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=11") e.DataRow("NOV")= Total111 Total112=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'and 年份=" & str & " and 月份=12") e.DataRow("DEC")= Total112 \' Else Dim Total1 As Single Dim Total2 As Single Total1=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= \'"& e.DataRow("零件ID") & "\'") Total2=DataTables("生产记录").Compute("Sum(成本小计)","零件ID= \'"& e.DataRow("零件ID") & "\'") e.DataRow("总工时")= Total1 e.DataRow("生产成本")= Total2 \'e.DataRow("单位成本")= Total2 / e.DataRow("入库数量") If e.DataRow("入库数量") = 0 e.DataRow("单位成本") = 0 Else e.DataRow("单位成本")= Total2 / e.DataRow("入库数量") End If \'End If End If |
-- 作者:有点蓝 -- 发布时间:2018/10/19 17:37:00 -- Single改为Double,或者Decimal试试 |