Here's my existing code. Thoughts?
Code:
Private Sub Define_ID_NotInList(NewData As String, Response As Integer)
'https://datatofish.com/how-to-create-to-a-yes-no-message-box-in-ms-access/
'Enhanced Message Box Replacement
'http://blog.nkadesign.com/2008/05/20/ms-access-enhanced-message-box-replacement/#comment-28080
Dim ClickResult As VbMsgBoxResultEx
ClickResult = Dialog.RichBox("The acronym/term doesn't appear to be in the database. Would you like to add it?", vbYesNo + vbCritical, "Not on list", , , 0, False, False, False)
If (ClickResult = vbYes) Then
'VBA Command to be executed if Yes is selected
'Removes the text you typed in that wasn't on the list and deletes the row that was just created
Me.Undo
'https://access-programmers.co.uk/forums/showthread.php?t=132051
'Closes the form you had tried to add a value to that failed.
DoCmd.Close acForm, "f_Key_Events", acSavePrompt
'Opens the form you are going to re-search for the value before adding it as a new record.
DoCmd.OpenForm "f_Definition"
'https://docs.microsoft.com/en-us/office/vba/api/access.form.setfocus
Forms!f_Definition!textsearch.SetFocus
ClickResult = Dialog.RichBox("Please check for the acronym/term again before adding a new record", vbOKOnly, "Check before adding", , , 0, False, False, False)
'Turn off the NotOnList Error
Response = acDataErrContinue
ElseIf (ClickResult = vbNo) Then
'VBA Command to be executed if No is selected
'Highlights the text you typed in since you're going to try and figure out what the real abbreviation is.
Response = acDataErrContinue
Me.Undo
Me.Define_ID.SetFocus
Exit Sub
End If
End Sub