Using the NotInList event (combo)

December 27, 2008 at 3:29 pm Leave a comment

The functionality of combo boxes can be extended significantly by adding a bit of code to the NotInList event which gets triggered when the LimitToList property is set to Yes and the user enters text that is not listed in the combo.

It can be made to add new records, change existing search fields, and so on. Your first line of code should be:

   DoCmd DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD, , A_MENU_VER20

You can then do what you like, because you have the new value that the user typed in to the NewData parameter and the original data is still available in the field. I generally open a modal form asking if the user wishes to add a new record or change the existing one, and then take appropriate action in the recordset.

The only trick is to end the NotInList subroutine with

   Response = DATA_ERRCONTINUE

This forces Access to ignore the error condition which originated the trigger for the NotInList subroutine.

This tip was supplied by aburkhol@compusmart.ab.ca (Armin Burkholder), May 16, 1995.

Entry filed under: Ms Access. Tags: .

Filter a Form on a Field in a Subform Using the Macro Recorder

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 14 other followers

Blog Stats

  • 94,725 hits

Twitter Updates

Iklan


%d bloggers like this: