NotInList Event

14 May

From:    “Sofyan Efendi” <>
Date:    Wed, 23 Aug 2006 14:19:27 +0700

Event NotInList terjadi ketika user memasukkan suatu nilai kedalam combo box, dimana nilai yang telah dimasukkan tersebut ternyata tidak ada pada daftar combo box tersebut. Syntax:

Private Sub object_NotInList( NewData As String, Response As Integer)


– Object: Nama combo box control.

– NewData: Nilai yang baru dimasukkan.

– Response: Constants yang dapat diset sbb:

. acDataErrDisplay (Default) -> Displays the default message to the user. You can use this when you don’t want to allow the user to add a new value to the combo box list.
. acDataErrContinue -> Doesn’t display the default message to the user. You can use this when you want to display a custom message to the user. For example, the event procedure could display a custom dialog box asking if the user wanted to save the new entry. If the response is Yes, the event procedure would add the new entry to the list and set the Response argument to . acDataErrAdded -> If the response is No, the event procedure would set the Response argument to acDataErrContinue. acDataErrAdded Doesn’t display a message to the user but enables you to add the entry to the combo box list in the NotInList event procedure. After the entry is added, Microsoft Access updates the list by requerying the combo box. Microsoft Access then rechecks the string against the combo box list, and saves the value in the NewData argument in the field the combo box is bound to. If the string is not in the list, then Microsoft Access displays an error message.


Private Sub Colors_NotInList( NewData As String, _
Response As Integer)
Dim ctl As Control
‘ Return Control object that points to combo box.
Set ctl = Me!Colors
‘ 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
‘ If user chooses Cancel, suppress error message
‘ and undo changes.
Response = acDataErrContinue
End If
End Sub

Wassalaamu’alaikum Warahmatullahi Wabarakatuh,
Sofyan Efendi
– AccessWeb <;
– OPI-Homepage <;


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: