|
Question : Trapping 2237
|
|
I'm trying to trap error 2237 in a combo box, when a user enters an item that isn't in the list. The following is the After_Update code that powers the combo box.
Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[PersonID] = " & Me![cmbName] If Not rs.EOF Then Me.Bookmark = rs.Bookmark cmbCRN.Value = "" cmbPostcode.Value = ""
I've tried to trap 2237 in the Before_update and Change events but I still get the generic Access message. Where should the error handler go?
|
|
Answer : Trapping 2237
|
|
The best I came up with is:
Private Sub cmbName_NotInList(NewData As String, Response As Integer) cmbName.Undo Response = acDataErrContinue End Sub
No more message, but it still drops down the combo once.
For your mechanism to work, I would bind the name column and remove "Limit To List". You can still use the ID column for your search, e.g.:
If Me.cmbName.ListIndex < 0 Then cmdName = Null Exit Sub End If ' [...] rs.FindFirst "PersonID = " & Me.cmbName.Column(1)
Hope this helps. (°v°)
|
|
|
|