I
Ivica Lopar
I have error in this code.Help please.
regards
lopar
Private Sub Task_NotInList(NewData As String, Response As Integer)
Dim db As Database
Dim LSQL As String
Dim LResponse As Integer
Dim ctl As Control
On Error GoTo Err_Execute
'Category combo box control
Set ctl = Me!Task
LResponse = MsgBox(NewData & " ni v seznamu. Ali ga zeliz dodati v
seznam?", vbYesNo, "Add Item")
'User responded "Yes" to adding the new item to the combo box
If LResponse = vbYes Then
Set db = CurrentDb()
'Insert new item into underlying table
LSQL = "insert into Tasks (Task) values ('" & NewData & "')"
db.Execute LSQL, dbFailOnError
Set db = Nothing
'Set Response argument to indicate that data is being added.
Response = acDataErrAdded
Else
'Set Response argument to suppress error message and undo changes
Response = acDataErrContinue
ctl.Undo
End If
On Error GoTo 0
Exit Sub
Err_Execute:
ctl.Undo
MsgBox "Action failed"
End Sub
regards
lopar
Private Sub Task_NotInList(NewData As String, Response As Integer)
Dim db As Database
Dim LSQL As String
Dim LResponse As Integer
Dim ctl As Control
On Error GoTo Err_Execute
'Category combo box control
Set ctl = Me!Task
LResponse = MsgBox(NewData & " ni v seznamu. Ali ga zeliz dodati v
seznam?", vbYesNo, "Add Item")
'User responded "Yes" to adding the new item to the combo box
If LResponse = vbYes Then
Set db = CurrentDb()
'Insert new item into underlying table
LSQL = "insert into Tasks (Task) values ('" & NewData & "')"
db.Execute LSQL, dbFailOnError
Set db = Nothing
'Set Response argument to indicate that data is being added.
Response = acDataErrAdded
Else
'Set Response argument to suppress error message and undo changes
Response = acDataErrContinue
ctl.Undo
End If
On Error GoTo 0
Exit Sub
Err_Execute:
ctl.Undo
MsgBox "Action failed"
End Sub