Hello, Access Users!
Situation:
I have Simply two tables - Patients and PatiensInfo. Also I have two forms with the same names.
So I use ComboBox in order to add not existing record. Everything seems ok, but here is a NotInList code:
One question would be: how to make the form "Patients"(which will pop up as a dialog box to add new info about new record) have filled the values I entered in combo box, so I will not need to re-enter ?
Hint: there are two values(or maybe 3 as I do not know if [ID] counts as one) in the combo box - [ID] and [First Name] & ' ' & [Last Name].
Situation:
I have Simply two tables - Patients and PatiensInfo. Also I have two forms with the same names.
So I use ComboBox in order to add not existing record. Everything seems ok, but here is a NotInList code:
PHP:
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
Forms![Patients]![First Name] = NewFirst
Forms![Patients]![Last Name] = NewLast
'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
One question would be: how to make the form "Patients"(which will pop up as a dialog box to add new info about new record) have filled the values I entered in combo box, so I will not need to re-enter ?
Hint: there are two values(or maybe 3 as I do not know if [ID] counts as one) in the combo box - [ID] and [First Name] & ' ' & [Last Name].