My Combo10 correctly finds records it its form.
This NotInList event correctly adds any new Customer entered in the combo.
When I select the new Customer from the combo's drop-down list the form doesn't update and open a new record for this Customer, but stays where it was before the NotInList fired.
This is the combo's AfterUpdate, where I've tried forcing a save and turning any filter off. They don't resolve the problem, but closing and reopening the form does.
This NotInList event correctly adds any new Customer entered in the combo.
Code:
Private Sub Combo10_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "New customer...")
If i = vbYes Then
strSQL = "Insert Into Customers ([Customer]) values ('" & NewData & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
When I select the new Customer from the combo's drop-down list the form doesn't update and open a new record for this Customer, but stays where it was before the NotInList fired.
This is the combo's AfterUpdate, where I've tried forcing a save and turning any filter off. They don't resolve the problem, but closing and reopening the form does.
Code:
Private Sub Combo10_AfterUpdate()
On Error GoTo Combo10_AfterUpdate_Err
If Me.Dirty Then Me.Dirty = False
Me.FilterOn = False
DoCmd.SearchForRecord , "", acFirst, "[CustomerID] = " & Str(Nz(Screen.ActiveControl, 0))
Me.Combo10 = Null
Combo10_AfterUpdate_Exit:
Exit Sub
Combo10_AfterUpdate_Err:
MsgBox Error$
Resume Combo10_AfterUpdate_Exit
End Sub