S
S.Low
I have a form for entering new jobs. I select a customter
from a combo box and the results of that filter another
combo box with customer contacts. I need to track
individuals that actually bring in the job. I am trying to
set up a not in list event that will 1. open a form
2. add the new contact, company name, and account # to the
form
3. After I close the contact form-update the combo box.
Step 3 is the problem. Steps 1 and 2 work fine, however
when I close the new contact form, and the new job form
has focus, I get the not in list message again when I move
from the contact field. I tried requery action and it
gives an error message about saving the current record.
The code I am using is below. Can someone please tell me
what I am missing, besides a orking knowledge of vba.
Thanks
Private Sub ContactID_NotInList(NewData As String,
Response As Integer)
Dim Form As String
Dim ctl As ComboBox
Dim Msg As String
Dim CR As String
Form = "frmAddContactfromNewJob"
Set ctl = ContactID
CR = Chr$(13)
Msg = "' " & NewData & "' is not in the contact list for"
& CR & CR
Msg = Msg & "this customer. Do you want to add this name?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
Response = acDataErrContinue
DoCmd.OpenForm Form, acNormal, , , acFormAdd
Forms!frmAddContactfromNewJob.Contact = NewData
Forms!frmAddContactfromNewJob.AccountNo = Forms!
frmNewWorkOrder.Key
Forms!frmAddContactfromNewJob.Company = Forms!
frmNewWorkOrder.AccountNo.Column(1)
Else
Response = acDataErrContinue
ctl.Undo
End If
End Sub
from a combo box and the results of that filter another
combo box with customer contacts. I need to track
individuals that actually bring in the job. I am trying to
set up a not in list event that will 1. open a form
2. add the new contact, company name, and account # to the
form
3. After I close the contact form-update the combo box.
Step 3 is the problem. Steps 1 and 2 work fine, however
when I close the new contact form, and the new job form
has focus, I get the not in list message again when I move
from the contact field. I tried requery action and it
gives an error message about saving the current record.
The code I am using is below. Can someone please tell me
what I am missing, besides a orking knowledge of vba.
Thanks
Private Sub ContactID_NotInList(NewData As String,
Response As Integer)
Dim Form As String
Dim ctl As ComboBox
Dim Msg As String
Dim CR As String
Form = "frmAddContactfromNewJob"
Set ctl = ContactID
CR = Chr$(13)
Msg = "' " & NewData & "' is not in the contact list for"
& CR & CR
Msg = Msg & "this customer. Do you want to add this name?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
Response = acDataErrContinue
DoCmd.OpenForm Form, acNormal, , , acFormAdd
Forms!frmAddContactfromNewJob.Contact = NewData
Forms!frmAddContactfromNewJob.AccountNo = Forms!
frmNewWorkOrder.Key
Forms!frmAddContactfromNewJob.Company = Forms!
frmNewWorkOrder.AccountNo.Column(1)
Else
Response = acDataErrContinue
ctl.Undo
End If
End Sub