Below is a look at my NotInList. The problem is that it will not tell you that the Organization is not in the current list, and will not add. It just goes to the next record.
Private Sub ORGANIZATION_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 Organization " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add the new Organization to the current list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new Organization?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Organization", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!ORGANIZATION = 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
My first NotInList event works fine. They are basically the same one is just asking for SSN and the other Organization.
Can someone help me figure out what the problem is.
Thank you
Private Sub ORGANIZATION_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 Organization " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add the new Organization to the current list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new Organization?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Organization", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!ORGANIZATION = 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
My first NotInList event works fine. They are basically the same one is just asking for SSN and the other Organization.
Can someone help me figure out what the problem is.
Thank you