'************ Code Start **********
Private Sub cbxAEName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String

    strMsg = "'" & NewData & "' is not an available AE Name"
    strMsg = strMsg & "Do you want to associate the new Name to the current DLSAF?"
    strMsg = strMsg & "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("tblAE", dbOpenDynaset)
        On Error Resume Next
        rs.AddNew
            rs!AEName = NewData
        rs.Update
       
        If Err Then
            MsgBox "An error occurred. Please try again."
            Response = acDataErrContinue
        Else
            Response = acDataErrAdded
       
    End If

Set db = Nothing
rs.Close
Set rs = Nothing
End Sub
'*********** Code End **************

posted on 2005-01-19 09:46  James Wong   阅读(365)  评论(0编辑  收藏  举报