I cannot get the not in list event to work right.
On my form I have a combo box named "cboChargeC ode"
I have a table named "tblChargeC ode"
I would like it so when you enter a value into the cbohargeCOde that is not listed it will alert you and ask you if you would like to add such item.
My code
error occurs on line:
I got this code form Microsoft so...
not sure what is going on or why it doesnt work, any help would be awesome!
Thanks
On my form I have a combo box named "cboChargeC ode"
I have a table named "tblChargeC ode"
I would like it so when you enter a value into the cbohargeCOde that is not listed it will alert you and ask you if you would like to add such item.
My code
Code:
Private Sub ChargeCode_NotInList(NewData As String, Response As Integer) Dim strSQL As String Dim i As interger 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 Charge Code...") If i = vbYes Then strsql = "Insert into tblChargeCode ([strChargeCode])" & CurrentDb.excute strSQL, dbFailOnError Response = acDataErrAdded Else Response = acDataErrContinue End If
Code:
strsql = "Insert into tblChargeCode ([strChargeCode])" & CurrentDb.excute strSQL, dbFailOnError
not sure what is going on or why it doesnt work, any help would be awesome!
Thanks
Comment