J
jv
Here is my code for a combobox Not in List (to add a new
record if the applicant's name is not there):
Private Sub Combo56_NotInList(NewData As String, Response
As Integer)
Dim Db As Database
Dim rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the list." &
vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Response = acDataErrContinue
Set Db = CurrentDb
Set rs = Db.OpenRecordset("tblApplicant",
dbOpenDynaset)
rs.AddNew
rs![Applicant1Name] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub
Answering "no" to adding a new name works but
answering "yes" results in the message: The text you
entered is not an item in the list.
The Limit to List is set to Yes for the combo box.
record if the applicant's name is not there):
Private Sub Combo56_NotInList(NewData As String, Response
As Integer)
Dim Db As Database
Dim rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the list." &
vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Response = acDataErrContinue
Set Db = CurrentDb
Set rs = Db.OpenRecordset("tblApplicant",
dbOpenDynaset)
rs.AddNew
rs![Applicant1Name] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub
Answering "no" to adding a new name works but
answering "yes" results in the message: The text you
entered is not an item in the list.
The Limit to List is set to Yes for the combo box.