Combobox - Allow a user to add values to the underlying Value List
faq181-110
I used the code in the faq181-110 and when I try to compile the code it errors on the Status.RowSource as not being defined.
I am using Access 2007, has something changed where this bit of code will no longer work?
faq181-110
I used the code in the faq181-110 and when I try to compile the code it errors on the Status.RowSource as not being defined.
I am using Access 2007, has something changed where this bit of code will no longer work?
Code:
Private Sub cboLevel_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboLevel_NotInList
Dim ctl As Control
Dim strSQL As String
' Return Control object that points to combo box.
Set ctl = Me!Status
' Prompt user to verify they wish to add new value.
If MsgBox("Item 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 value list
Status.RowSource = [COLOR=red]Status.RowSource[/color] & ";" & NewData
ctl.Value = NewData
Else
' If user chooses Cancel, suppress error message and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
Exit_cboLevel_NotInList:
Exit Sub
Err_cboLevel_NotInListt:
MsgBox Err.Description
Resume Exit_cboLevel_NotInList
End Sub