On Jul 11, 2:21 pm, richal...@cs.com wrote:
> I'm using following notinlist event code for a number of cbo's on a
> form (that are all very similar), yet this particular one fails to
[quoted text clipped - 6 lines]
> Can anyone suggest a possible cause (and remedy) for this problem?
> TIA, Richard
Sorry, but I forgot to include the code:
Private Sub CoPolicyType_NotInList(NewData As String, Response As
Integer)
' Add a new policy type by typing a name in
' CoPolicy Type combo box.
Dim NewCoPolicyType As Integer, TruncateName As Integer, Title As
String, MsgDialog As Integer
Const MB_OK = 0
Const MB_YESNO = 4
Const MB_ICONQUESTIONMARK = 32
Const MB_ICONEXCLAMATION = 64
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
' Display message box asking if user wants to add a
' new insurer.
Title = "Policy Type Not In List"
MsgDialog = MB_YESNO + MB_ICONQUESTIONMARK + MB_DEFBUTTON1
NewCoPolicyType = MsgBox("Do you want to add a new Policy Type?",
MsgDialog, Title)
If NewCoPolicyType = IDYES Then
' Display message box and adjust length of
value entered in
' PolicyType combo box.
Title = "Name Too Long"
MsgDialog = MB_OK + MB_ICONEXCLAMATION
If Len(NewData) > 25 Then
TruncateName = MsgBox("Policy names can be no longer than
25 characters. The name you entered will be truncated.", MsgDialog,
Title)
NewData = Left$(NewData, 25)
End If
' Open Add Policy form.
DoCmd.OpenForm FormName:="FPolicyTypeCo", DataMode:=acAdd,
WindowMode:=acDialog, openargs:=NewData
' Continue without displaying default error message.
Response = acDataErrContinue
End If
End Sub
Graham Mandeno - 12 Jul 2007 00:21 GMT
Hi Richard
Your NotInList event procedure should return a Response value of
acDataErrAdded to indicate that the new value has been added so the combo
box should be automatically requeried.
The Response value acDataErrContinue should be used if the new value has NOT
been added (the user answered "No" to the question), otherwise you will get
the default "not in list" message as well as your own one.
Also, there are built-in constants that you should be using instead of the
ones you are declaring. They are: vbOKOnly, vbYesNo, vbQuestion,
vbExclamation, vbDefaultButton1, vbYes and vbNo.

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
> On Jul 11, 2:21 pm, richal...@cs.com wrote:
>> I'm using following notinlist event code for a number of cbo's on a
[quoted text clipped - 50 lines]
>
> End Sub
richaluft@cs.com - 12 Jul 2007 04:35 GMT
On Jul 11, 7:21 pm, "Graham Mandeno" <Graham.Mand...@nomail.please>
wrote:
> Hi Richard
>
[quoted text clipped - 73 lines]
>
> > End Sub
Graham: I'll give your suggestions a try, but I remain confused, as
follows.
I'm using essentially identical notinlist events in 4 other cbos on
the same form (all with dataerrcontinue), and in the other 4 my coding
works perfectly (includeng the old constants. I can't explain why
opnly 2 don't function properly.
Ill get back to you with the results of your suggestions.
Richard
richaluft@cs.com - 13 Jul 2007 01:24 GMT
On Jul 11, 11:35 pm, richal...@cs.com wrote:
> On Jul 11, 7:21 pm, "Graham Mandeno" <Graham.Mand...@nomail.please>
> wrote:
[quoted text clipped - 85 lines]
> Ill get back to you with the results of your suggestions.
> Richard
Tried to use Added, rather than continue, but now get constant msg on
entering new data of:
:the text you entered isnt an item in the list". Needless to say,
recordsource table for data is also not being updated with new data.
Any other suggestions from anyone?
Graham Mandeno - 17 Jul 2007 12:47 GMT
Sorry Richard - I missed your follow-up here.
> Tried to use Added, rather than continue, but now get constant msg on
> entering new data of:
> :the text you entered isnt an item in the list". Needless to say,
> recordsource table for data is also not being updated with new data.
> Any other suggestions from anyone?
If the "recordsource table for data is also not being updated with new data"
then the problem is with the form you are opening to add the new data record
(FPolicyTypeCo). If it is now successfully adding a new record to your
RowSource, with a text field exactly matching NewData then you will get the
"isn't an item in the list" message.
Just to clarify:
acDataErrContinue means "assume this error has been handled and pass
control back to the user interface (but don't let me leave this combo box if
the error has not been rectified)"
and
acDataErrAdded means "I have added a new row to the data source which
matches what the user entered, so requery it and IF everything is OK then
quit bugging me"

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
Graham Mandeno - 17 Jul 2007 22:20 GMT
> (FPolicyTypeCo). If it is now successfully adding a new record to your
Sorry - that should be "If it is NOT ..."