Hello, I am using the following code in Not in List Event:
Private Sub SeedTrader_IDsup1_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
Dim CR As String
CR = Chr$(13)
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
DoCmd.OpenForm "SeedTraderForm", , , , acAdd, acDialog, NewData
End If
Result = DLookup("[SdTrName]", "tblSeedTrader", _
"[SdTrName]='" & NewData & "'")
If IsNull(Result) Then
Response = acDataErrContinue
MsgBox "Please try again!"
Else
Response = acDataErrAdded
End If
End Sub
The Code repeats two times in a Form (In case the same Trader is also a broker or Agent). Is it possible to create a Function and refer to the control?
Regards
Alex