D
Dave
The message board contains numerous posting regarding the NotInList event. I
used most of the suggested code with the exception of a popup form. For some
reason, I can't get Access 2003 to stop displaying the "text not in list ..."
error message. The new item appears in the box unselected so when it is
selected, the problem goes away. I checked the cbobox listcount property and
it doesn't increase after acDataErrAdded. So what might I be missing? The
code is below:
Private Sub ShipVia_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 ShipVia choice. " &
vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the current
DM?"
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("tblShip", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs.Fields("ShipVia").Value = NewData
rs.Update
lg = rs!ShipID
rs.Close
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Set rs = Nothing
Set db = Nothing
End Sub
Always appreciate the help.
used most of the suggested code with the exception of a popup form. For some
reason, I can't get Access 2003 to stop displaying the "text not in list ..."
error message. The new item appears in the box unselected so when it is
selected, the problem goes away. I checked the cbobox listcount property and
it doesn't increase after acDataErrAdded. So what might I be missing? The
code is below:
Private Sub ShipVia_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 ShipVia choice. " &
vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the current
DM?"
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("tblShip", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs.Fields("ShipVia").Value = NewData
rs.Update
lg = rs!ShipID
rs.Close
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Set rs = Nothing
Set db = Nothing
End Sub
Always appreciate the help.