C
CJ
Hi Groupies:
I have the following code in a combo box on a subform.
Private Sub CreatedBy_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & "Add " & NewData & " to the list? "
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEmployees", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!EmpLast = NewData
rs.Update
DoCmd.OpenForm "frmEmployees", acNormal, , , acFormAdd
If Err Then
' MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Me.CreatedBy.Value = Null
Me.dtmDate.SetFocus
Me.CreatedBy.Requery
End Sub
The problem is that I can not get the new item to show up in the combo
unless the user pushes F9 or changes records.
Can anybody provide some insight into what I am missing?
I have the following code in a combo box on a subform.
Private Sub CreatedBy_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & "Add " & NewData & " to the list? "
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblEmployees", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!EmpLast = NewData
rs.Update
DoCmd.OpenForm "frmEmployees", acNormal, , , acFormAdd
If Err Then
' MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Me.CreatedBy.Value = Null
Me.dtmDate.SetFocus
Me.CreatedBy.Requery
End Sub
The problem is that I can not get the new item to show up in the combo
unless the user pushes F9 or changes records.
Can anybody provide some insight into what I am missing?