当用户输入新记录时,我有以下检测重复的产品名称。
JSON.parse(data): Unexptected end of JSON Input.
代码检查并找到重复但在显示以下错误后不会转到原始记录:
运行时错误'3420' 对象无效或不再设置
有人可以帮助我做对吗?
答案 0 :(得分:0)
尽量避免撤消(或将其移至最后)并取消更新:
If DCount("ProdName", "ProdProduct", stLinkCriteria) > 0 Then
Cancel = True
MsgBox "Warning duplicate entry " _
& Product & " has already been entered." _
& vbCr & vbCr & "You will now be taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original product name
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
您甚至可以跳过 DCount 并且必须使用 Text 属性:
Product = Me!ProdName.Text
stLinkCriteria = "[ProdName]=" & "'" & Product & "'"
rsc.FindFirst stLinkCriteria
Cancel = Not rsc.NoMatch
If Cancel = True Then
MsgBox "Warning duplicate entry " _
& Product & " has already been entered." _
& vbCr & vbCr & "You will now be taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original product name
Me.Bookmark = rsc.Bookmark
End If