Results 1 to 12 of 12
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Combo, "NotInList" event doesn't fire


    I want to take some special action when a user keys in a string that's not in the list. I started with some simple test code:
    Code:
    Private Sub cboDescriptions_NotInList(NewData As String, Response As Integer)
    MsgBox "Not in List " & NewData
    End Sub
    I don't get my test message when I type in a string that's not in the list. Below is a screenshot of the combo's Event properties:

    Click image for larger version. 

Name:	000.jpg 
Views:	20 
Size:	49.1 KB 
ID:	42131

    What might I be missing.............. that is, besides a brain I mean

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is LimitToList property set to Yes?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    "LimitToList" property is set to "NO"
    Click image for larger version. 

Name:	001.jpg 
Views:	19 
Size:	49.8 KB 
ID:	42133

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Set it to Yes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I did mention something about my "brain"............ SIGH!
    So, all I need to do now is suppress the message from Access so I can move on with the action I want taken when entered text isn't in the list?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks, I got all of that. I just need to temporarily suppress:
    Click image for larger version. 

Name:	002.jpg 
Views:	17 
Size:	39.3 KB 
ID:	42137
    DoCmd.SetWarnings False doesn't seem to get the job done. I tried to turn warnings off while the code serviced the text string and then back on when the combo lost the focus but the warning persists.

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    you didn't show your code or explain what you want to do but you'll probably have to use acDataErrContinue or acDataErrAdded

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    BlueClaw code shows that. Here's another https://www.devhut.net/2010/06/12/ms...in-list-event/
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I'll add more code asking user, but for now I'm just trying to get the addition of a new item successfully added. Here's the event code:
    Code:
     
    Private Sub cboDescriptions_NotInList(NewData As String, Response As Integer)
    
    CurrentDb.Execute "INSERT INTO tblRegDescriptions (Description) VALUES(""" & NewData & """);"
    DoCmd.Save acTable, "tblRegDescriptions"
    Me.cboDescriptions = Null
    Me.cboDescriptions.Requery
    Response = acDataErrContinue
    
    End Sub
    I keep getting the 2489 error: (Even though the insert was in fact successful)

    Click image for larger version. 

Name:	005.jpg 
Views:	10 
Size:	18.0 KB 
ID:	42177

    The error goes away if I remove the DoCmd.Save statement. Now, if I can just get the combo to collapse without having to select the newly added text I'm done. (I'll capture NewData first)

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    DoCmd.Save has nothing to do with saving data, it is to save design changes. Remove that line.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    GOT IT! Just had to do things in the right order.
    Code:
    Private Sub cboDescriptions_NotInList(NewData As String, Response As Integer)
    
    CurrentDb.Execute "INSERT INTO tblRegDescriptions (Description) VALUES(""" & NewData & """);"
    'DoCmd.Save acTable, "tblRegDescriptions"
    Me.cboDescriptions = Null
    Me.cboDescriptions.Requery
    Me.tbNewDescription.SetFocus
    Me.cboDescriptions.Visible = False
    Me.tbNewDescription = NewData
    
    Response = acDataErrContinue
    
    Call tbNewDescription_AfterUpdate
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-12-2019, 09:47 AM
  2. Replies: 2
    Last Post: 04-17-2017, 11:26 PM
  3. Replies: 3
    Last Post: 02-06-2015, 03:22 PM
  4. Replies: 7
    Last Post: 01-19-2011, 10:39 AM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums