Not in the List Code Question

  • Thread starter Thread starter scott04
  • Start date Start date
S

scott04

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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top