The user found a problem with the code listed below. If they happen to type in the SSN in the form where another document was already opened. When it ask if they want to add to the current list it overrides the SSN that was originally there and put the new number in place of the data. Is there a way when it saves to the current list the rest of the fields become blank?
Private Sub SSN_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 SSN " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add the new SSN to the current list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new SSN?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("SSN", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!SSN = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub
Private Sub SSN_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 SSN " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add the new SSN to the current list?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new SSN?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("SSN", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!SSN = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub