这两个位置总是报错,是怎么回事儿
调用的目标发生了异常。
未将对象引用设置到对象的实例。
Dim bh1 As String
Dim bh2 As String
If e.DataRow.IsNull("接样日期") Then
e.DataRow("委托单编号") = Nothing
Else
Dim bh As String = Format(e.DataRow("接样日期"),"yyyyMMdd") '取得编号的8位前缀
If e.DataRow("委托单编号").StartsWith(bh) = False '如果编号的前8位不符
Dim max As String
Dim idx As Integer
max = DataTables("理化_统计总表").Compute("Max(委托单编号)","接样日期 = #" & e.DataRow("接样日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(8,2)) + 1 '获得最大编号的后2位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
bh1 = bh & Format(idx,"00")
Dim dr1 As DataRow = DataTables("理化_已有编号").SQLFind("编号 = '"& bh1 &"'")
If dr1 Is Nothing
e.DataRow("委托单编号") = bh1
Else
bh2 = bh1
For i As Integer = 1 To 100
bh1 = val(bh2) + i
Dim dr2 As DataRow = DataTables("理化_已有编号").SQLFind("编号 = '"& bh1 &"'")
If dr2 Is Nothing
e.DataRow("委托单编号") = bh1
Return
End If
Next
End If
End If
msgbox("1-3")
End If