Dim BHTEMP As String
BHTEMP=format(e.Form.Controls("DateTimePicker2").Value,"yyyyMMdd") 可能错误的地方.
Dim max As String
Dim idx As Integer
max = Tables("bmk").Compute("Max(BH)","substring([bh],5,8) = ' " & bhtemp & "'" ) 可能错误的地方.
If max>"" Then
idx = CInt(max.Substring(10)) + 1
Else
idx = 1
End If
另外注意表达式的Substring, 第一个字符的编号是1,不是0.