combobox fields

adil_karampurwa

Registered User.
Local time
Today, 09:09
Joined
Sep 18, 2006
Messages
23
In the from "send mail" i have a combox "to" which is bounded to a field "names" in the table "email". i want new names to be added to the list automatically so In its "notinlist" event i have put this code...
and getting an error plz help

Private Sub txtTo_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Book Category...")
If i = vbYes Then
strSQL = "Insert Into tblemail ([names]) values ('" & NewData & "')"

CurrentDb.Execute strSQL, dbFailOnError
'error is variable dbFailOnError not defined..:confused:
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom