我正在创建一个数据库,我想为每个条目生成一个 UniqueReference - 格式为 YY-0000。在表单中,我放置了一个带有以下代码的按钮,但它出现语法错误,我不知道如何修复它。
Private Sub Command39_Click()
Dim vLast As Variant
Dim iNext As Integer
vLast = DMax("[UniqueReference]", "[ScammerInfo]", "[UniqueReference]" & Format([DateCreated], "yy\*\'"))
If IsNull(vLast) Then
iNext = 1
Else
iNext = Val(Right(vLast, 4)) + 1
End If
Me![UniqueReference] = Format([txtDateCreated], "yy") & "-" & Format(Next, "0000")
End Sub
我用谷歌搜索过,但我发现的任何东西对我来说都没有任何意义
尝试使用这一行:
Me![UniqueReference].Value = Format([DateCreated], "yy\-") & Format(Nz(DMax("[UniqueReference]", "[ScammerInfo]", "[UniqueReference] Like '" & Format([DateCreated], "yy\-????") & "'")) + 1, "0000")