acNewRec 不适用于组合框 NotInList
acNewRec doesn't work for combobox NotInList
我在 Access 表单中有 ComboBox。它显示来自 db table 的项目列表。如果找不到项目,我想创建此记录。所以我使用 NotInList 事件:
Private Sub Combo9_NotInList(NewData As String, Response As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
当我尝试在 ComboBox 中输入不存在的项目时,出现错误:
但我创建了按钮并添加了相同的代码 onClick 事件,它工作正常。
NotInList 有什么问题?我如何使用此事件添加新记录?
您需要清除错误和输入的任何内容。
Private Sub cboSelect_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
MsgBox "New entries are not permitted." & vbCrLf & vbCrLf & _
"Please select an entry from the list or " & vbCrLf & _
"move to a new record and add a new item below. ", , _
"MsgBox Title"
Me.cboSelect.Undo
End Sub
我在 Access 表单中有 ComboBox。它显示来自 db table 的项目列表。如果找不到项目,我想创建此记录。所以我使用 NotInList 事件:
Private Sub Combo9_NotInList(NewData As String, Response As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
当我尝试在 ComboBox 中输入不存在的项目时,出现错误:
但我创建了按钮并添加了相同的代码 onClick 事件,它工作正常。
NotInList 有什么问题?我如何使用此事件添加新记录?
您需要清除错误和输入的任何内容。
Private Sub cboSelect_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
MsgBox "New entries are not permitted." & vbCrLf & vbCrLf & _
"Please select an entry from the list or " & vbCrLf & _
"move to a new record and add a new item below. ", , _
"MsgBox Title"
Me.cboSelect.Undo
End Sub