jeffmoseler
Well-known Member
- Joined
- Jul 16, 2004
- Messages
- 540
I have a combo box with an not in list event that adds a record to the table it is bound with. After it adds it, the combo box seems to be struggling with re-selecting the added record. I have a feeling that it is because I need to update the record source of the main form, but if I do that then I loose the currently selected record on the form. How do I update the record source of the form and keep the currently selected record?
Or maybe I'm missing something and there's another way. I posted the not in list event code below.
Or maybe I'm missing something and there's another way. I posted the not in list event code below.
Code:
Private Sub cmbCurrentIns_NotInList(NewData As String, Response As Integer)
Dim oRS As DAO.Recordset, i As Integer, sMsg As String
Dim oRSClone As DAO.Recordset
Response = acDataErrContinue
If MsgBox("Add " & NewData, vbYesNo) = vbYes Then
Set oRS = CurrentDb.OpenRecordset("tblInsurers", dbOpenDynaset)
oRS.AddNew
oRS.Fields(1) = NewData
oRS.Update
cmbCurrentIns = Null
cmbCurrentIns.Requery
End If
End Sub