I would like to use a function for my not in list. I use the combo box on may forms, and would like simplify things by using a function.
Here is the code I've tried. It works as a subroutine, but when trying it as a function I am not sure how to transfer the NewData and Response:
Here is the code I've tried. It works as a subroutine, but when trying it as a function I am not sure how to transfer the NewData and Response:
Code:
Public Function EnterNewJob(NewData As String, Response As Integer)
Dim x As String
Dim frm As String
Dim ctl As String
frm = Screen.ActiveForm.Name
ctl = Screen.ActiveControl.Name
x = frm & "|" & ctl
Response = acDataErrContinue
Forms(frm).Controls(ctl).Undo
Dim ans As Variant
gbl_exit_name = False
ans = MsgBox("Contract Entered is not in the Database. Do you want to add it?", _
vbYesNo, "Add New Contract?")
If ans = vbNo Then
Forms(frm).Controls(ctl) = Null
DoCmd.GoToControl ctl
GoTo exit_it
End If
' add Project
DoCmd.OpenForm ("frmEnterNewProject"), , , , , , x
Form_frmEnterNewProject.NameOfJob = NewData
exit_it:
Forms(frm).Controls(ctl).Value = NewData
End Function
Last edited: