A
Afrosheen via AccessMonster.com
Thank you for taking the time to read this.
I have a combo box called cmboSupervisor. The control source is Supervisor
from the supervisor table.
I have an event {not in list} that is not working correctly. What I want to
have happen is when I enter a name {Joe} and it's not in the list, it will
ask me if I want to add it to the list. When I select yes then it's supposed
to put Joe in the Supervisor table and open the Supervisor form with Joe in
the supervisor field. Then be able to add more information. This is the code:
Private Sub CmboSupervisor_NotInList(NewData As String, Response As Integer)
Dim strMsg, stWhere As String
10 On Error GoTo CmboSupervisor_NotInList_Error
20 strMsg = "'" & NewData & "' is not in the Supervisor list. Are you sure
you want to add it?"
30 If MsgBox(strMsg, vbYesNo + vbDefaultButton2) = vbYes Then
40 Response = acDataErrAdded
50 DoCmd.OpenForm "copy of frmSupervisor", , , "Supervisor = " & Chr(34)
& NewData & Chr(34), , acDialog, NewData
60 Else
70 Response = acDataErrContinue
80 Me.cmboSupervisor.Undo
90 End If
100 On Error GoTo 0
110 Exit Sub
CmboSupervisor_NotInList_Error:
120 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CmboSupervisor_NotInList of VBA Document Form_frmEmployee_Tab"
End Sub
I don't know where the problem is and any help would be appreciated.
I have a combo box called cmboSupervisor. The control source is Supervisor
from the supervisor table.
I have an event {not in list} that is not working correctly. What I want to
have happen is when I enter a name {Joe} and it's not in the list, it will
ask me if I want to add it to the list. When I select yes then it's supposed
to put Joe in the Supervisor table and open the Supervisor form with Joe in
the supervisor field. Then be able to add more information. This is the code:
Private Sub CmboSupervisor_NotInList(NewData As String, Response As Integer)
Dim strMsg, stWhere As String
10 On Error GoTo CmboSupervisor_NotInList_Error
20 strMsg = "'" & NewData & "' is not in the Supervisor list. Are you sure
you want to add it?"
30 If MsgBox(strMsg, vbYesNo + vbDefaultButton2) = vbYes Then
40 Response = acDataErrAdded
50 DoCmd.OpenForm "copy of frmSupervisor", , , "Supervisor = " & Chr(34)
& NewData & Chr(34), , acDialog, NewData
60 Else
70 Response = acDataErrContinue
80 Me.cmboSupervisor.Undo
90 End If
100 On Error GoTo 0
110 Exit Sub
CmboSupervisor_NotInList_Error:
120 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CmboSupervisor_NotInList of VBA Document Form_frmEmployee_Tab"
End Sub
I don't know where the problem is and any help would be appreciated.