Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

errant notinlist event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richaluft@cs.com - 11 Jul 2007 19:21 GMT
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
work properly.
After event is triggered, form is opened, and data entered, my cbo
shows a blank value, and remains uneditable.  Re-entering the same
info does not help.
I have a requery command event in the ongotfocus event of the cbo (as
I have for all of the properly working cbo's).
Can anyone suggest a possible cause (and remedy) for this problem?
TIA, Richard
richaluft@cs.com - 11 Jul 2007 19:22 GMT
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 ..."
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.