Below is the code in the NotInList Event of a combo box. This will add the value not in the list to the table and refresh the list (that works fine and the combo box is correct). Next I open the form ReasonCode so the user can update other fields for this record. ReasonForm does not have the record I added, but when I go to the table, it is there. Why? Is there a better way?
Dim ctl As Control
Dim strLinkCriteria As String
' Return Control object that points to combo box.
Set ctl = Me!cboReasonCode
' Prompt user to verify they wish to add reason code.
If MsgBox("Not in list. Add it?", vbOKCancel) = vbOK Then
Set dbADR = OpenDatabase("c:\wrk\devel adr.mdb"
Set recADR = dbADR.OpenRecordset("reason"
recADR.MoveLast
recADR.AddNew
recADR!ReasonCode = NewData
recADR.Update
recADR.Close
dbADR.Close
'Save Change on form
Me![cboReasonCode].Value = NewData
'Don't display error since we are handeling it
Response = acDataErrContinue
'Requery the combo box on the form
ctl.Requery
'Open ReasonForm for the new record to update
DoCmd.OpenForm "ReasonForm"
End If
Dim ctl As Control
Dim strLinkCriteria As String
' Return Control object that points to combo box.
Set ctl = Me!cboReasonCode
' Prompt user to verify they wish to add reason code.
If MsgBox("Not in list. Add it?", vbOKCancel) = vbOK Then
Set dbADR = OpenDatabase("c:\wrk\devel adr.mdb"
Set recADR = dbADR.OpenRecordset("reason"
recADR.MoveLast
recADR.AddNew
recADR!ReasonCode = NewData
recADR.Update
recADR.Close
dbADR.Close
'Save Change on form
Me![cboReasonCode].Value = NewData
'Don't display error since we are handeling it
Response = acDataErrContinue
'Requery the combo box on the form
ctl.Requery
'Open ReasonForm for the new record to update
DoCmd.OpenForm "ReasonForm"
End If