I have an open form, where the combo box gathers data from a 'Traveldetail'. If the user doesn't find the item in the combobox, he should enter the new item in the combo box, where the notinlist is triggered and should allow the user to add the new item in the 'Traveldetail'.
code:
Private Sub Destination_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
' Return Control object that points to combo box.
Set ctl = Me!Destination
' 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.
DoCmd.OpenForm [TravelDetails], acFormDS, , , acFormAdd
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub
i am not able to do this. I tried many option and failed. please help!
code:
Private Sub Destination_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
' Return Control object that points to combo box.
Set ctl = Me!Destination
' 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.
DoCmd.OpenForm [TravelDetails], acFormDS, , , acFormAdd
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
End Sub
i am not able to do this. I tried many option and failed. please help!
Last edited: