Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    38

    Unanswered: NotInList error message

    I am not very good with writing code so please be gentle with me. I have written NotInList code and it works in all but one of my databases. I am getting the following message "The text you entered isn't an item on the list - Select an item on the list or enter text that matches one of the listed items" when I look at the table the new entry is there - so why can't I select it?

    Below is the code. Where am I going wrong?

    Private Sub cmboAccount_number_NotInList(NewData As String, Response As Integer)
    On Error GoTo cmboAccountNumber_NotInList_Err
    Dim intAnswer As Integer
    Dim strSql As String
    intAnswer = MsgBox("The account number " & Chr(34) & NewData & Chr(34) & " is not currently listed." & vbCrLf & "Would you like to add it to the list now?", vbQuestion + vbYesNo, "tblAccountNumber")
    If intAnswer = vbYes Then
    strSql = "INSERT INTO tblAccountNumber([Account Number]) " & "VALUES ('" & NewData & "');"
    DoCmd.SetWarnings False
    DoCmd****nSQL strSql
    DoCmd.SetWarnings True
    MsgBox "The new account number has been added to the list.", vbInformation, "tblAccountNumber"
    Response = acDataErrAdded
    Else
    MsgBox "Please choose an account number from the list.", vbInformation, "tblAccountNumber"
    Response = acDataErrContinue
    End If
    cmboAccountNumber_NotInList_Exit:
    Exit Sub
    cmboAccountNumber_NotInList_Err:
    MsgBox Err.Description, vbCritical, "Error"
    Resume cmboAccountNumber_NotInList_Exit
    End Sub

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by kim burke View Post

    ...so why can't I select it...
    Are you saying the item appears in the Combobox but you cannot select it, or it doesn't appear in the Combobox, even though it is now in the underlying Table?

    If the latter, after adding the item to the Table, the Combobox would have to be Requeried before the new item would appear.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    is the code running

    put a breakpoint on the function call and step through the code. see if it breaks at the function

    then step through the code and examine what is actually happeneing
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Aug 2007
    Posts
    38
    it is now in the underlying Table as I have discovered I can use the drop down to find and select it. I use this NotInList for half a dozen other combo boxes in the database and I don't have to requery them. Could there be some other setting that has mistakenly been changed?

  5. #5
    Join Date
    Aug 2007
    Posts
    38
    I have solved my problem thanks to a reply to another post I had. The problem was something to do with two blank entries in my table. So I am a happy camper. Thanks for your assistance.

Posting Permissions

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