和列长度没有什么关系。应该表格有些旧的不合规范的编码导致的
max = Tables("产品资料库").DataTable.SQLCompute("Max(开发项目编码)","建档日期 = '" & e.DataRow("建档日期") & "' And [_Identify] <> " & e.DataRow("_Identify") & " and 开发项目编码 like 'CPKF%'") '取得该天的最大编号
If max > "" Then '如果存在最大编号
msgbox(max) ‘这里显示什么?
idx = CInt(max.Substring(max.length - 3,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If