when this add to combo code is fired i get a variable undefined error on the first line.
surely this is defining the variables itself?
Private Sub taskcombo_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
DoCmd.SetWarnings (warningsoff)
If MsgBox("OK to add new Task type.?. Or Press Cancel to Discard", vbOKCancel + vbwarning, "Add Equip Type?") = vbOK Then
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tbl_task", dbOpenDynaset)
' On Error Resume Next
Rs.AddNew
Rs![task] = NewData
Rs.Update
Set Db = Nothing
' Continue without displaying default error message.
Response = acDataErrAdded
Else
DoCmd.SetWarnings (warningsoff)
Response = acDataErrContinue
Me.Undo
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
Me!taskcombo.Requery
End If
End Sub
surely this is defining the variables itself?
Private Sub taskcombo_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
DoCmd.SetWarnings (warningsoff)
If MsgBox("OK to add new Task type.?. Or Press Cancel to Discard", vbOKCancel + vbwarning, "Add Equip Type?") = vbOK Then
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tbl_task", dbOpenDynaset)
' On Error Resume Next
Rs.AddNew
Rs![task] = NewData
Rs.Update
Set Db = Nothing
' Continue without displaying default error message.
Response = acDataErrAdded
Else
DoCmd.SetWarnings (warningsoff)
Response = acDataErrContinue
Me.Undo
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
Me!taskcombo.Requery
End If
End Sub