Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NotInList Event Still fires default error Msg in Access 2002

Status
Not open for further replies.

dpatrickcollins

Programmer
Nov 18, 2002
79
Hi Folks,

I have read various thread regarding the NotInList Event, but none answer this simple question. Consider the code:

Private Sub ClientCompanyName_NotInList(NewData As String, Response As Integer)
Response = acDataErrAdded
End Sub

Should this code prevent the standard Microsoft Error, "The item you added . . . " from being fired. If not, then how? Please note that Access 2002's help for NotInList Event is all but absent.
 
Hi,

The 'notinlist' event has 'default' code, i.e. "The item you added . . . ".

If you decide to place your own response in there, then you override the standard error message - just as it should.

If you want the original message, then why change it?

If you look for help on the 'acDataErrAdded' constant, it tells you clearly that it stops the error message so that you can add the missing item to the list. (Therefore you don't need an error message, 'cos the item IS then in the list).

Regards,

Darrylle






"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Hi,

Not sure what you are trying to do. acDataErrContinue will suppress the default message, or you could do something like this:

Response = acDataErrContinue
MsgBox "You have entered an invalid item. Press the Esc key to undo!", vbOKOnly, "My Message"

Bill


 
Trap it on the Form Error Event it is Error 2237 '* Not on List...

Dim fshowIt As Boolean

Err.Number = DataErr
Err.Description = AccessError(DataErr)

fshowIt = True

Select Case DataErr

Case 2237
'* place custom message here or none and no message will be
'* displayed.
fshowit=false

End Select

'* Purpose: Having trapped the error and done what we want with it,
'* (Which in this example is merely to display a different error msg
'* from the standard one, but could include other actions)
'* we no longer want to display Access' standard error msg,
'* so suppress it.

If fshowIt = True Then
'* Place default error handler here.

Response = acDataErrContinue
Else
Response = acDataErrContinue
End If




Life's a journey enjoy the ride...

jazzz
 
Thanks, all who have responded. Though the code I posted was for demonstration purposes, my actual code (or shall I say, code elsewhere) was the culprit. The combo box data source applied a filter to the underlying table. The added item did not meet the filter criteria. When adding the new item via code, I added the data value for it to meet the criteria, and no more error message.

However, I did not find ANY online help for the response enumeration values and scant else. I am using Access 2002 and have used Access 2000. Same problem. Any help with this would be appreciated.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top