You haven't posted the code that may be running in the second form
"RefDocs", so it's hard to say what may be happening there. And, I don't
know what the setup of that form is and what it's doing. You may be
triggering the NotInList event the second time via that form. Please provide
more info.
In the code you did post, you do need to add one code step for the option of
when the person does not want to add the value:
If byteResponse = vbOK Then
DoCmd.OpenForm "RefDocs", , , , acFormAdd, acDialog, "newdoc;" & NewData
Combo26.SetFocus
Response = acDataErrAdded
Else
Combo26.Value = Null
Response = acDataErrContinue
[RefDoc] = 0
End If
By putting Response = acDataErrAdded step in, you should not need the
following steps:
Me.Requery 'this <I think> reprompts the NotInList routine. Should
[Response] be something
'different?
Me.Refresh
I typically use Integer variables for receiving responses to message boxes,
not Byte variables. I haven't tested what you've posted, but I'll assume
that it's working ok for you.
--
Ken Snell
<MS ACCESS MVP>
Stephen Rockower said:
The following is my NotInList routine. The RefDocs form uses NewData in the
OnOpen for adding a new record and beginning to input the new info.
Even
if
the requery and refresh lines are commented out, I still get my reprompt
("Do you want to add this doctor?"). What am I doing wrong here???
TIA
Steve
Public Sub Combo26_NotInList(NewData As String, Response As Integer)
'4.30.03
'12.30.03 getting closer. still need to figure out the notinlist parameters
On Error GoTo NotInList_Err
Dim byteResponse As Byte
byteResponse = MsgBox("Do you want to add this doctor?", vbOKCancel, "COR
Dictations")
If byteResponse = vbOK Then
DoCmd.OpenForm "RefDocs", , , , acFormAdd, acDialog, "newdoc;" & NewData
Combo26.SetFocus
Response = acDataErrAdded
Else
Combo26.Value = Null
[RefDoc] = 0
End If
Me.Requery 'this <I think> reprompts the NotInList routine. Should
[Response] be something
'different?
Me.Refresh
Exit Sub
NotInList_Err:
MsgBox Err.Number & " " & Err.Description
Resume Next
End Sub