R
Renee
So I put this event into my form but once I say yes to the question 'Add new
name?' it gives me a msg box that says 'An error occurred. Please try again."
I know that this msg box is set up in the event so I cannot figure out where
the error is. Any ideas on how I can figure out where the error is?
This is how the event looks:
Private Sub VENDOR_ID_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 " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the current
DLSAF?"
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("PARTS VENDOR T", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!VENDOR_ID = 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
name?' it gives me a msg box that says 'An error occurred. Please try again."
I know that this msg box is set up in the event so I cannot figure out where
the error is. Any ideas on how I can figure out where the error is?
This is how the event looks:
Private Sub VENDOR_ID_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 " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the current
DLSAF?"
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("PARTS VENDOR T", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!VENDOR_ID = 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