I have a form "FrmTeamData" in which combo box control "TxtServiceNumber" has the following code in the "Not in List" event:
Code:
Private Sub Service_Number_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Service_Number_NotInList
'Service Number not recognised
Dim intAnswer As Integer
intAnswer = MsgBox("Add Competitor Details?", vbYesNo, vbQuestion)
If intAnswer = vbYes Then
DocName = "FrmCompDetails"
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm DocName, acNormal, , , acFormEdit, acDialog
DoCmd.GoToRecord acDataForm, DocName, acNewRec
DoEvents
Forms(DocName).Controls("TxtServiceNumber").Value = NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Exit_Service_Number_NotInList:
Exit Sub
Err_Service_Number_NotInList:
MsgBox Err.Description
Resume Exit_Service_Number_NotInList:
End Sub
I enter a service number in the combo box and, if it is not listed in TblCompDetails, I get the message box. What I then want is for the number I have entered in the combobox to appear in the "TxtServiceNumber" control on FrmCompDetails, so that I don't have t type it in again.
I used the code that was suggested by PHV in Thread 705-1278130 but this does not work and the form opens with a blank control.
Could someone please take a look at my code and see where it is going wrong.
Thanks a lot
John