Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a combo box where my logic is falling over. I am using the on exit event to deal with the text section of the combo being left empty and the user pressing return. That works fine. However the not in list event fails if I select create new addition. The not in list code contains a value set (PP) to allow it through the on exit event after the not in list sequence is dealt with.

    Hope the rough flowchart identifies where I am going wrong. Thanks
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you want to add the data entered by the user in the On Not In List event, you must:
    - Explicitly add the value (represented by the NewValue argument of the event procedure) to the row source of the combo box.
    - Set the Response argument to acDataErrAdded.
    - Not undo the combo box - that would defeat the purpose.

    Adding NewValue to the row source can be done by executing an SQL statement with INSERT INTO. See for example Post 159332.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans. I am not wanting the item added to the combo list!! I want the user to go through the process of answering questions on a form until it is saved at the end after selecting save. The combo gets hidden and a textbox appears where the combo was, holding the new item. Is there another way round the problem? Regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't really understand what you want to do, but I suspect it won't work. Trying to go against the grain usually causes problems in Access.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. What I am trying to do is let the user see a combo full of items. When they type an item in the textbox and the not in list event kicks in, I want to effectively put what the user had typed in into a textbox, and make the add the item not add the item and then make the combo hidden just showing the textbox. Does that make sense? Regards

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    But why this bizarre, convoluted method? I'd say:
    - If the user wants to add the item to the list, add it to the list (after performing a check, if necessary).
    - If the user does not want to add the item to the list, do not add it to the list.
    Simple and effective...

  7. #7
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, I know it looks crazy, but the user has to enter a lot more data in before everyting gets saved. The part here is just 5% of the overall data. I think I will go back to using a listbox, and if its not in the list then its easier to save the new item in a variable for later. Just thought as combo's had a not in the list event, and were smaller, it was the way to go, however not. Best regards

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you want the user to add other information needed to add a new record to the row source, you can display a form from the On Not In List event. See for example Post 138353.

  9. #9
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans. I got what I wanted in the end.

    Response = False

    If MsgBox("The Folder " & UCase(NewData) & " does not exist. Create it?", vbYesNo) = vbYes Then
    Me.PF = UCase(NewData) ' Put what the user typed into a textbox
    Me.Combo2.Undo
    Response = False
    Cancel = True
    SendKeys "{tab}"
    Else
    Me.PF = ""
    Me.Combo2.Undo
    Response = False
    Cancel = True
    ' Return to combo textbox to allow redoing typed input (if mistake made), or pressing enter
    ' to abort
    End If

    Regards

Posting Permissions

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