Access 2003
How to add a value not in the list to a bound combo box
Problem: The meesage box never comes up when I enter
a value that is not in the combo box.
Name: Product_Name
Limit To List: No
The combo box is bounded to a table that has only
one field. The name of this field is Product_Name.
I even set the Limit To List property to Yes, but the
message box still won 't comes up.
//////////////////////////////////////
Private Sub Product_Name_NotInList(NewData As String,
Response As Integer)
Dim ctl As Control
' Return Control object that points to combo box.
Set ctl = Me!Product_Name
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", vbOKCancel)
= vbOK Then
' Set Response argument to indicate that
'data is being added.
Response = acDataErrAdded
' Add string in NewData argument to row source.
ctl.RowSource = ctl.RowSource & ";" & NewData
Else
' If user chooses Cancel,
'suppress error message and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub
How to add a value not in the list to a bound combo box
Problem: The meesage box never comes up when I enter
a value that is not in the combo box.
Name: Product_Name
Limit To List: No
The combo box is bounded to a table that has only
one field. The name of this field is Product_Name.
I even set the Limit To List property to Yes, but the
message box still won 't comes up.
//////////////////////////////////////
Private Sub Product_Name_NotInList(NewData As String,
Response As Integer)
Dim ctl As Control
' Return Control object that points to combo box.
Set ctl = Me!Product_Name
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", vbOKCancel)
= vbOK Then
' Set Response argument to indicate that
'data is being added.
Response = acDataErrAdded
' Add string in NewData argument to row source.
ctl.RowSource = ctl.RowSource & ";" & NewData
Else
' If user chooses Cancel,
'suppress error message and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub