G
Guest
I setup a query called NameQuery which as fields of:
expr1: which is a persons last name then first name
SubjectNum: subject number
I have a combo box cboSearch which us using the query NameQuery to get the
persons last name then first name.
The code below is what I used to have just to search by a SubjectNum in the
table Patient_Registry
What I would like to do is when a persons name is selected in the cboSearch
and a button is pushed it then displays the persons information from the
Patient_Registry. How can I modify the code below to do this, or do I have
to start over completely.
Thanks for the help
Private Sub Search_Click()
Dim subjectnum As Long
If IsNull(txtSearch.Value) Or (DLookup("[SubjectNum]",
"Patient_Registry", "[SubjectNum]=" & txtSearch.Value)) <> 0 Then 'Exit Sub
' checks to see if random number is duplicated
subjectnum = DLookup("[SubjectNum]", "Patient_Registry",
"[SubjectNum]=" & txtSearch.Value)
' Make sure the entered subjectnum exists in the database
' Move the record pointer to the entered subject num
Me.Filter = "[SubjectNum] = " & subjectnum
Me.FilterOn = True
Me.Refresh
txtSearch.Value = 1
AddPatient.Caption = "Save Patient's Information"
Else
If txtSearch.Value <> 0 Then
MsgBox ("Subject Number not found!")
Else
txtSearch.Value = 0
End If
End If
End Sub
expr1: which is a persons last name then first name
SubjectNum: subject number
I have a combo box cboSearch which us using the query NameQuery to get the
persons last name then first name.
The code below is what I used to have just to search by a SubjectNum in the
table Patient_Registry
What I would like to do is when a persons name is selected in the cboSearch
and a button is pushed it then displays the persons information from the
Patient_Registry. How can I modify the code below to do this, or do I have
to start over completely.
Thanks for the help
Private Sub Search_Click()
Dim subjectnum As Long
If IsNull(txtSearch.Value) Or (DLookup("[SubjectNum]",
"Patient_Registry", "[SubjectNum]=" & txtSearch.Value)) <> 0 Then 'Exit Sub
' checks to see if random number is duplicated
subjectnum = DLookup("[SubjectNum]", "Patient_Registry",
"[SubjectNum]=" & txtSearch.Value)
' Make sure the entered subjectnum exists in the database
' Move the record pointer to the entered subject num
Me.Filter = "[SubjectNum] = " & subjectnum
Me.FilterOn = True
Me.Refresh
txtSearch.Value = 1
AddPatient.Caption = "Save Patient's Information"
Else
If txtSearch.Value <> 0 Then
MsgBox ("Subject Number not found!")
Else
txtSearch.Value = 0
End If
End If
End Sub