Results 1 to 2 of 2
  1. #1
    rnjalston is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Posts
    2

    Combobox help

    I have 4 comboboxes each filtered by the previous. When entering a new record, it asks if I want to add the record....answer yes, and the record is added. However, if I add a record in the first combobox and proceed to the next and add a new record to the next combobox, they are not related properly. What code do I need to add to get this to function properly?

    Here is the current code for the 2nd combobox:
    ' If Entered Product is not in List allow add.
    Private Sub cboProduct_NotInList(NewData As String, Response As Integer)
    'Supress the default error message.
    Response = acDataErrContinue
    'Ask user if they want to add the new Product to the list/database
    If MsgBox(NewData & " is not in list of Products. Add it?", vbYesNo) = vbYes Then
    Dim db As Database
    Dim rstProducts As Recordset
    Dim sqlProducts As String


    Set db = CurrentDb()
    sqlProducts = "Select * From Products"
    'Create a new recordset to add the new PRODUCT to the database.
    Set rstProducts = db.OpenRecordset(sqlProducts, dbOpenDynaset)
    rstProducts.AddNew
    rstProducts![Product] = NewData
    rstProducts![ManufacturerID] = cboMfg.Value
    rstProducts.Update
    'Inform the combobox that the desired item has been added to the list.
    Response = acDataErrAdded
    rstProducts.Close 'Close the recordest
    End If
    End Sub


    Please help,
    Thanks

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    At the end of the NotInList routine, requery the related combo box if a value is added.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. help with combobox
    By ManC in forum Forms
    Replies: 0
    Last Post: 03-15-2010, 08:27 PM
  2. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  3. ComboBox Autocomplete
    By AdrianKitchen in forum Forms
    Replies: 3
    Last Post: 10-13-2009, 11:12 AM
  4. Combobox problem
    By newitsupport in forum Access
    Replies: 1
    Last Post: 09-26-2009, 01:03 PM
  5. ComboBox Row Source Value
    By mpbertha in forum Forms
    Replies: 1
    Last Post: 08-21-2009, 06:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums