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