Its like you knew.... Yes you are correct. I am using the after update to accomplish the task of adding the selected email to the text box(collection of emails) Also, I want the newly added email to go there as well. I haven't coded it yet as I wanted to get past this speedbump first.
Private Sub cbonewEmail_AfterUpdate()
Me.txtEmailStr = Me.txtEmailStr & ";" & cbonewEmail.Column(0)
Me.Refresh
End Sub
Sub for 'not in list' is some code I found that defines a function for adding the new entry to the table. You just call it and put in the parameters which I do and am fairly certain there isn't an error there.
Public Function AddNewToList(NewData As String, stTable As String, _
stFieldName As String, strPlural As String, _
Optional strNewForm As String) As Integer
On Error GoTo err_proc
'Adds a new record to a drop down box list
'If form name passed, then open this form to the newly created record
'Declare variables
Dim rst As DAO.Recordset
Dim IntNewID As Long
Dim strPKField As String
Dim strMessage As String
' Display message box asking if user wants to add the new item
strMessage = "'" & NewData & "' is not in the current list. " & Chr(13) & Chr(13) & _
"Do you want to add it to the list of " & strPlural & "?" & Chr(13) & Chr(13) & _
"(Please check the entry before proceeding)."
If MsgBox(strMessage, vbYesNo + vbQuestion + vbDefaultButton2, "Add New Data") = vbYes Then
Set rst = CurrentDb.OpenRecordset(stTable, , dbAppendOnly)
rst.AddNew
rst(stFieldName) = NewData 'Add new data from combo box
strPKField = rst(0).Name 'Find name of Primary Key (ID) Field
rst.Update
rst.Move 0, rst.LastModified
IntNewID = rst(strPKField)
'if a form specified, then open the form with the primary key equal to the new record ID as the criteria
If strNewForm <> "" Then DoCmd.OpenForm strNewForm, , , strPKField & "=" & IntNewID, , acDialog
AddNewToList = acDataErrAdded 'Set response 'Data added'
Else
AddNewToList = acDataErrContinue 'Set response 'Data NOT added'
End If
exit_proc:
On Error Resume Next
rst.Close
Set rst = Nothing
Exit Function
err_proc:
MsgBox "Error in Function: 'AddNewToList'" & Chr(13) & Err.Description, , "Function Error"
Resume exit_proc
End Function