J
John
I am having trouble with the NotInList event on a combobox (actually several
similar comboboxes).
When I enter data that is not in the combobox list, I sometimes (but not
always!) get the "You have entered data that is not on the list." error
message, in spite of the NotInList procedure which should add the new item to
the table which is the rowsource for the combobox. I can't find any pattern
to when I get the message and when I don't.
I have verified that the data has in fact been entered onto the table, but
it is not showing up on the combobox list. If I undo and retype the data, I
get a duplicate key error (in fact, occasionally I get a duplicate key error
the first time I enter new data!). The combobox has only a single column.
The table ttmpCboSpecColor is the RowSource for cboSpecColor, and is located
in the FE of a split FE/BE mulituser database (this is a workaround to
improve a performance issue caused by comboboxes requerying from the BE on
the server). It has a single field called "SpecColor" which is set as the
primary key.
Here is the code for the NotInList event procedure:
Private Sub cboSpecColor_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboSpecColor_NotInList
Dim rs As DAO.Recordset
'Add item to table which is combobox rowsource.
Set rs = CurrentDb.OpenRecordset("ttmpCboSpecColor", dbOpenDynaset)
With rs
.AddNew
!SpecColor = NewData
.Update
End With
Response = acDataErrAdded
Exit_cboSpecColor_NotInList:
On Error Resume Next
'Release object variable.
rs.Close
Set rs = Nothing
Exit Sub
Err_cboSpecColor_NotInList:
'Notify user and exit.
MsgBox Err.Description, vbExclamation, "Unable to update combobox: error
#" & Err.Number
Response = acDataErrContinue
Resume Exit_cboSpecColor_NotInList
End Sub
It seems as though the acDataErrAdded response is not functioning. Can
anyone help?
Thanks in advance,
John
similar comboboxes).
When I enter data that is not in the combobox list, I sometimes (but not
always!) get the "You have entered data that is not on the list." error
message, in spite of the NotInList procedure which should add the new item to
the table which is the rowsource for the combobox. I can't find any pattern
to when I get the message and when I don't.
I have verified that the data has in fact been entered onto the table, but
it is not showing up on the combobox list. If I undo and retype the data, I
get a duplicate key error (in fact, occasionally I get a duplicate key error
the first time I enter new data!). The combobox has only a single column.
The table ttmpCboSpecColor is the RowSource for cboSpecColor, and is located
in the FE of a split FE/BE mulituser database (this is a workaround to
improve a performance issue caused by comboboxes requerying from the BE on
the server). It has a single field called "SpecColor" which is set as the
primary key.
Here is the code for the NotInList event procedure:
Private Sub cboSpecColor_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboSpecColor_NotInList
Dim rs As DAO.Recordset
'Add item to table which is combobox rowsource.
Set rs = CurrentDb.OpenRecordset("ttmpCboSpecColor", dbOpenDynaset)
With rs
.AddNew
!SpecColor = NewData
.Update
End With
Response = acDataErrAdded
Exit_cboSpecColor_NotInList:
On Error Resume Next
'Release object variable.
rs.Close
Set rs = Nothing
Exit Sub
Err_cboSpecColor_NotInList:
'Notify user and exit.
MsgBox Err.Description, vbExclamation, "Unable to update combobox: error
#" & Err.Number
Response = acDataErrContinue
Resume Exit_cboSpecColor_NotInList
End Sub
It seems as though the acDataErrAdded response is not functioning. Can
anyone help?
Thanks in advance,
John