Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    NotInList Event Doesn't Save NewData on Form Close (2000)

    I have this code in the NotInList Event of a combo box (Location).

    Private Sub Location_NotInList(NewData As String, Response As Integer)
    Dim ctl As Control
    Set ctl = Me!LOCATION
    If MsgBox("Value is not in list. Add it?", vbYesNo) = vbYes Then
    Response = acDataErrAdded
    ctl.RowSource = ctl.RowSource & ";" & NewData
    Else
    Response = acDataErrContinue
    ctl.Undo
    End If
    Set ctl = Nothing
    End Sub

    The code works while you have the form open and are adding new records, the new value is shown in the combo box drop down list. But when I close the form and open it back up the new value doesn't appear in the drop down list.

    The combo box is a bound control to the Location field of a table. The row source type is a value list and the row source is a list separated by semi-colons.

    What am I missing?

    Sarah

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

    Re: NotInList Event Doesn't Save NewData on Form Close (2000)

    If your combo box has a value list as row source, it will be initialized to the list you set in the Properties window in design view each time you open the form. The items you add while in form view are kept in memory, but not stored in the form. If you want to store the items permanently, you must use a table as row source, and use the Not In List event to append the new item to the table.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: NotInList Event Doesn't Save NewData on Form Close (2000)

    Thanks, that worked.

    Too bad that simple code couldn't do the trick.

    Sarah

Posting Permissions

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