On Not In List/After Update Events

G

Guest

I have the follwing code for OnNotInList and AfterUpdate Events:

Private Sub Steward_s_Name_NotInList(NewData As String, Response As Integer)
If MsgBox("The Union Representative's name you entered was not found, do you
want to add the name you entered?", _
vbYesNo + vbQuestion, _
"Please Respond") = vbYes Then
DoCmd.OpenForm "UnionRepsList", _
Datamode:=acFormAdd, _
WindowMode:=acDialog, _
OpenArgs:=NewData
If IsLoaded("UnionRepsList") Then
Response = acDataErrAdded
DoCmd.Close acForm, "UnionRepsList"
Else
Response = acDataErrContinue
End If
Else
Response = acDataErrContinue
End If
End Sub
================================================
Private Sub Steward_s_Name_AfterUpdate()
Me.Requery
Me.Refresh
End Sub
================================================
My problem is that after entering the new name in the form UnionRepsList,
the new name does not appear in the combo box named Steward's_Name. As a
consequence I cannot select the new name and I get the same error message
that the name is not in the list. After selecting a differnt name in the
combo box and after entering the next control, I can go back to the combo box
and see the newly entered name.

What is problem with my code?

Thanks for the help.
 
D

Douglas J. Steele

You're opening the UnionRepsList form in dialog mode, which means that the
code will stop executing until the form has been closed.

That means your check

If IsLoaded("UnionRepsList") Then
Response = acDataErrAdded
DoCmd.Close acForm, "UnionRepsList"
Else
Response = acDataErrContinue
End If

isn't correct. Try replacing that entire chunk of code with

Response = acDataErrAdded


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"(e-mail address removed).(donotspam)"
 
G

Guest

Doug:

It worked. I got the code I used from an Access 2000 book and modified it
for my use. I checked it again to make use I entered it correctly. Why
wouldn't the code you suggested be replaced not work for Access 2003? It
included the code: Response = acDataErrAdded.

Thanks again for the help.
 
D

Douglas J. Steele

What you had would have had the same issue in Access 2000. Authors of books
do occasionally make mistakes!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"(e-mail address removed).(donotspam)"
 

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

Similar Threads


Top