I have used the combo box wizard to add a search field to my form. It is set to Limit to List, and I have added code I got from the MSDN site to ask if you want to add a record if not in the list. My yes/no message box displays correctly, and the code to add the record fires. My issue is that it keeps looping back to the do you want to add this record message until I answer no. If I look in the table, I can see the new record, but it is not available in the form. After my INSERT statement, which seems to work, I turn the warnings back on and use
Code:
Response = acDataErrAdded
. I understand that acDataErrAdded is supposed to refresh the form, yet the new record is not available to me. My goal is to add the new record and then go to that record if the user answers "yes." Am I going about this the right way?
Code:
Dim intAnswer As Integer
intAnswer = "MsgBox("""" & NewData & """ is not available. " & vbCrLf _
& "Do you want to add it now?", vbYesNo + vbQuestion, "Not in List")
Select Case intAnswer
Case vbYes
DoCmd.SetWarnings False
DoCmd.RunSQL " INSERT INTO tblUnit(txtSerialNo)", _
& "Select """ & NewData & """;"
DoCmd.SetWarnings True
Response - acDataErrAdded
Case vbNo
MsgBox "Please select an item from the list.", _
vbExclamation + vbOKOnly, "Invalid Entry"
Me!Combo71.Undo
Response = acDataErrContinue
End Select