我有一个在 OnOpen 事件中打开的表单。部分事件包含以下代码:
nid = Val(DMax("id2", "claims", "yr =" & yr) + 1)
nid = Val(Nz([nid], 1))
但是,运行时出现“无效使用 Null”错误。有任何想法吗?
在下面编辑 这是完整的代码:
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Dim lngID As Long
Dim rs As Object
Set rs = Me.Recordset.Clone
lngID = Val(Me.OpenArgs)
rs.FindFirst "[ID] = " & lngID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
Me.LOGID.SetFocus
'Display Suggested ID Numbers
Dim yr As Long
Dim nid As Long
yr = Format(Date, "yy")
nid = Val(DMax("id2", "claims", "yr =" & yr) + 1)
nid = Val(Nz([nid], 1))
Me.SugID = yr & "-" & nid
End Sub