Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Dec 2000
    Location
    Rockhampton, Queensland, Australia
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo - NotInList (2K-SR2)

    How can I stop Not In List message from appearing when an unlisted item is entered.

    The NotInList event is triggered, and after exiting this event the mesage is then displayed and the cursor returned to the combo box. so the before or after update events do not occur.

    I've tried DoCmd.SetWarning False in the NotInList event to no avail.

    Any Ideas will be appreciated.

    Neville

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo - NotInList (2K-SR2)

    The NotInList event procedure has two arguments: NewData and Response.

    NewData contains the text entered by the user. You (the programmer) can use this to add this to the list, if desired.

    Response can be set to three different values:
    acDataErrDisplay - this is the default value; the standard error message will be displayed.
    acDataErrContinue - the standard error message is suppressed.
    acDataErrAdded - the value in NewData has been added to the list.

    Example: the code below is for a combo box cboPhoneType. Its row source is the table tblPhoneTypes with a single field PhoneType.

    When the user enters a non-existing type into the text box part of the combo box, the code asks whether this value should be added.

    If the user clicks Yes, an insert SQL statement is executed and Response is set to acDataErrAdded.

    If the user clicks No, the entry is undone and response is set to acDataErrContinue, so there is no error message.

    <img src=/w3timages/blueline.gif width=33% height=2>

    Private Sub cboPhoneType_NotInList(NewData As String, Response As Integer)
    Dim strSQL As String
    If MsgBox("The type " & NewData & " does not occur not in the list." & vbCrLf & _
    "Do you want to add it?@", vbYesNo + vbQuestion) = vbYes Then
    strSQL = "INSERT INTO tblPhoneTypes (PhoneType) VALUES (" & _
    Chr$(34) & NewData & Chr$(34) & ")"
    CurrentDb.Execute strSQL, dbFailOnError
    Response = acDataErrAdded
    Else
    cboPhoneType.Undo
    Response = acDataErrContinue
    End If
    End Sub

  3. #3
    New Lounger
    Join Date
    Dec 2000
    Location
    Rockhampton, Queensland, Australia
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo - NotInList (2K-SR2)

    That was simple, Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •