Ok now I have NotInList code like that:
Code:
Private Sub PatientLook_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_PatientLook_NotInList
Dim intAnswer As Integer
Dim strsql
Dim NewFirst As String
Dim NewLast As String
Dim SpacePosition As Integer
SpacePosition = InStr(NewData, " ")
If SpacePosition = 0 Then
MsgBox "Your value has no First Name."
Exit Sub
End If
NewLast = Trim(Left(NewData, SpacePosition - 1))
NewFirst = Trim(Mid(NewData, SpacePosition + 1))
intAnswer = MsgBox("Would you like to add this value to the list?", vbYesNo, vbQuestion)
If intAnswer = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "Patients", acNormal, , , acFormAdd, acDialog
strsql = "Insert Into Patients ([First Name], [Last Name]) values ('" & NewFirst & "','" & NewLast & "')"
CurrentForm.Execute strsql, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Exit_PatientLook_NotInList:
Exit Sub
Err_PatientLook_NotInList:
MsgBox Err.Description
Resume Exit_PatientLook_NotInList
End Sub
Something Is wrong in the Bolded area, how to set the values to the Form instead of a table ?