I'm trying to run the simple NotInList example provided in the Access2000 help file. The Code is as follows:
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
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub
End Sub
Now it says to assign this code to "the form" - I thought it had to be added to the OnNotInList command assigned to the combobox but it doesn't work - where in the "form" do I assign the code to make this run properly...
Also with every OTHER code I've ever tried - the Private Sub statement always gives me an error - the Sub only works when I remove the Private...
Any help would be greatly appreciated!
Cheers,
Himy
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
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub
End Sub
Now it says to assign this code to "the form" - I thought it had to be added to the OnNotInList command assigned to the combobox but it doesn't work - where in the "form" do I assign the code to make this run properly...
Also with every OTHER code I've ever tried - the Private Sub statement always gives me an error - the Sub only works when I remove the Private...
Any help would be greatly appreciated!
Cheers,
Himy