[英]Use MsgBox to open form to new record or delete record from continuous form if the record does not already exist
I have a form with a continuous subform that is used to "check out" items.我有一个带有连续子表单的表单,用于“签出”项目。 If an item is entered that is not currently in the
items
table, an error fires.如果输入的
items
当前不在items
表中,则会触发错误。
I would like to create a custom msgbox
that will allow the user to select the next action;我想创建一个允许用户选择下一个操作的自定义
msgbox
; either open a form to enter the new item (along with a number of details about the item) or to delete the row.打开一个表单以输入新项目(以及有关该项目的许多详细信息)或删除该行。
I have been able to fire the msgbox
code and successfully open the form to enter a new item, but I cannot get the row to delete from the subform OR use SetProperty
to return the value to null
.我已经能够触发
msgbox
代码并成功打开表单以输入新项目,但我无法从子表单中删除要删除的行或使用SetProperty
将值返回到null
。
Here is the current code to launch the MsgBox
which is triggered BeforeUpdate, OnError from the control in question.这是启动
MsgBox
的当前代码,该代码由相关控件触发 BeforeUpdate、OnError。
Function MsgBox_NewAsset()
MsgBoxResult = MsgBox("The Asset Number you entered is not in the system. Would you like to enter this as a new asset?", 4 + vbQuestion, "New Asset?")
If MsgBoxResult = 6 Then
DoCmd.SetWarnings False
DoCmd.OpenForm "Asset Details", , , "AssetID=0"
DoCmd.SetWarnings True
Else
DoCmd.SetProperty("AssetID",acPropertyValue,"")
End If
End Function
When setting the SetProperty
command using:使用以下命令设置
SetProperty
命令时:
DoCmd.SetProperty("AssetID",acPropertyValue,"")
I get a compile error:我收到一个编译错误:
Expected: =
预期:=
I'm relatively new to VBA, so not entirely sure what this indicates.我对 VBA 比较陌生,所以不完全确定这意味着什么。
Try DoCmd.RunCommand acCmdUndo
rather than DoCmd.SetProperty(...)
尝试
DoCmd.RunCommand acCmdUndo
而不是DoCmd.SetProperty(...)
The form is sitting on an uncommitted, new record that can't be committed.表单位于无法提交的未提交的新记录上。 To roll it back, use Undo.
要回滚它,请使用撤消。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.