Hi everyone, I am using the following code in the event an item isn't in my
list:
Private Sub Plaintiff_s_Firm_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Would you like to add a new
plaintiff's firm name?...")
If i = vbYes Then
strSQL = "Insert Into tblplaintiffs_firm_name
([Plaintiffs_firm_name]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
If I enter something that is not in the list it prompts me whether I want to
add it. If i select yes that i want to add it and hit ok, the code does work
and it does add it to the list. My only problem is that once i hit ok to add
it to the list, my next record "pops up". Is there something I can place in
my code such that if i hit ok to add it to the list that it stays in the
current record? Any help is appreciated.
scott04 - 30 Nov 2007 15:26 GMT
This only happens to go to the next record for example if i have to go back
into the form and change this field. If i enter it on a new record for
example there is no problems with the code.
Roger Carlson - 30 Nov 2007 15:56 GMT
Try setting the Cycle property of the form to "Current Record".

Signature
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
> This only happens to go to the next record for example if i have to go
> back
> into the form and change this field. If i enter it on a new record for
> example there is no problems with the code.
scott04 - 30 Nov 2007 16:19 GMT
Roger,
Thank you. It works perfectly now.
> Try setting the Cycle property of the form to "Current Record".
>
> > This only happens to go to the next record for example if i have to go
> > back
> > into the form and change this field. If i enter it on a new record for
> > example there is no problems with the code.