S
Song
The following NotInList will add new record but it is not shown on
current form until I close and reopen. When I add new data, I want the
form to show the newly added record so I can enter other information.
Private Sub cboGoto_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is new to lending. " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this record?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to re-
type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("contacts", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!SID = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
current form until I close and reopen. When I add new data, I want the
form to show the newly added record so I can enter other information.
Private Sub cboGoto_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is new to lending. " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this record?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to re-
type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("contacts", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!SID = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub