bob fitz
AWF VIP
- Local time
- Today, 07:24
- Joined
- May 23, 2011
- Messages
- 4,721
Can someone please look at this and tell me what I'm doing wrong.
The code adds the NewData to the table but I get a message which tells me, "The text you entered isn't an item in the list"
I think I must be having a "Senior Moment" because as far as I can see this is how I've always handled the NotInList event
The code adds the NewData to the table but I get a message which tells me, "The text you entered isn't an item in the list"
Code:
Private Sub cboCusFilter_NotInList(NewData As String, Response As Integer)
Dim rec As Recordset
If MsgBox("Add '" & StrConv(NewData, vbProperCase) & "' to the list of Customers?", vbYesNo, "Confirmation Required") = vbYes Then
' DoCmd.RunSQL "INSERT INTO tblCus (CusName) Select (""" & StrConv(NewData, vbProperCase) & """)"
Set rec = CurrentDb.OpenRecordset("tblCus")
With rec
.AddNew
.Fields("CusName") = StrConv(NewData, vbProperCase)
.Update
.Close
End With
Set rec = Nothing
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub