hi,
i have a combobox that pulls a list from a table, and i've added a "New" button to create a new blank record in the combobox (see below). when i have a new record (ID) in the combobox however, and want to fill that new recordset in, if the value i enter happens to be one that already exists in another record, it will CHOOSE that old record and make it "active," instead of filling in the new record with the new value...
so how do i make the combo box differentiate, ie. enter values into a new recordset even when those values happen to be similiar to already existing values?
new button create new record and adds perhaps the last name if available... (barely working code...)
thanks for any help..
i have a combobox that pulls a list from a table, and i've added a "New" button to create a new blank record in the combobox (see below). when i have a new record (ID) in the combobox however, and want to fill that new recordset in, if the value i enter happens to be one that already exists in another record, it will CHOOSE that old record and make it "active," instead of filling in the new record with the new value...
so how do i make the combo box differentiate, ie. enter values into a new recordset even when those values happen to be similiar to already existing values?
Code:
Private Sub NewC(curComboText As String) Dim strMsg As String Dim rstNewContact As DAO.Recordset strMsg = "'" & curComboText & "' is not in the list. " strMsg = strMsg & "Would you like to make a new Contact with " & curComboText & " as last name?" If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion + vbApplicationModal, "New Customer") Then Response = acDataErrDisplay 'Access displays its standard Error Message 'nuContact = False Else 'Decided to Add the New Customer EditMode (True) MsgBox "after editmode, curComboText=" & curComboText Set rstNewContact = CurrentDb.OpenRecordset("Contacts", dbOpenTable) With rstNewContact .Index = "PrimaryKey" ' .Seek "=", comboID ' If .NoMatch = False Then ' MsgBox "seek ok, " & comboID 'strIndex = !LastName ' MsgBox "last name is " & strIndex .MoveFirst .MoveLast .AddNew !LastName = curComboText .Update .MoveLast comboID = !ID .Seek "=", comboID MsgBox "nu comboid=" & comboID Form_Query18.Combo336.Value = comboID Form_Query18.Combo336.Requery MsgBox "new contact added, " & !LastName & " + " & !FirstName ' Else ' MsgBox "id not found?! " ' End If End With curID = rstNewContact("ID") curLN = rstNewContact("LastName") curMob = rstNewContact("Mobile") 'MsgBox curID & ", " & curLN & ", " & curMob & ", " & NewData & "+ " & varBookmark Response = acDataErrAdded 'Item added to underlying Recordset and the Combo 'Box is Requeried, Item added to List rstNewContact.Close Set rstNewContact = Nothing Form_Query18.Combo336.SetFocus Form_Query18.Combo340.Requery bTextCombo336 = "" End If End Sub
thanks for any help..
Comment