Results 1 to 4 of 4
  1. #1
    gdboling
    Guest

    COMBOBOX Problems

    I have a table : Lookup
    Has one column with FigureName

    I have a table : Entry
    Has Two columns, ID and FigureName

    The Entry table has the combo box
    Row Source is Lookup
    Bound to 1 column (Lookups FigureName)
    Limit to List set to Yes

    This is my on not in list form code

    On NotInPrivate Sub FigureName_NotInList(NewData As String, Response As Integer)


    Dim Db As DAO.Database
    Dim Rs As DAO.Recordset
    Dim Msg As String
    Dim CR As String

    CR = Chr$(13)


    ' Exit this subroutine if the combo box was cleared.
    If NewData = "" Then Exit Sub

    ' Confirm that the user wants to add the new Figure Name.
    Msg = "'" & NewData & "' is not in the list." & CR & CR
    Msg = Msg & "Do you want to add it?"
    If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
    ' If the user chose not to add a customer, set the Response
    ' argument to suppress an error message and undo changes.
    Response = acDataErrContinue
    ' Display a customized message.
    MsgBox "Please enter a different name."
    Else



    ' If the user chose to add a new Figure Name, open a recordset
    ' using the Lookup table.
    Set Db = CurrentDb
    Set Rs = Db.OpenRecordset("Lookup", dbOpenTable)
    ' Let code execution continue if a run-time error occurs.
    On Error Resume Next

    ' Create a new record.
    Rs.AddNew

    ' Assign the NewData argument to the FigureName field.
    Rs![FigureName] = NewData
    ' Save the record.
    Rs.Update

    MsgBox "Name Added"

    End If

    Rs.Close
    Me!Combo1.Requery
    End Sub

    I go into the form and enter a new name, it then prompts me if I would like to add that name. I click yes, it adds the name and then says "The text you entered isn't an item in the list". It still ads the name to the Lookup table, but not the Entry Table. It needs to be in both

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: COMBOBOX Problems

    You need to set the response argument to acDataErrAdded after the rs.update line. This will tell Access that the item has been added.

  3. #3
    gdboling
    Guest

    Re: COMBOBOX Problems

    THE FINAL KEY TO THE PUZZLE!!!! YOU ARE A GOD SENT.

    It finally works. Thank you soooo much.
    <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  4. #4
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: COMBOBOX Problems

    Glad you got it working. I neglected to mention that you shouldn't need to requery the combobox once the response is set.

Posting Permissions

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