G
Guest
I have a database in access97. In the database there is a form where the user
takes names of clients as they come. I want to check after the user enters
the first and last name if the name exist in the data base, if it does it
should alert the data entry person. I am using the following code which all
of the sudden stoped functioning the way it should, i.e. there are similar
name that the code missed:
start********************************
Dim strStaff As String, dteBirthDate As String,intMatchpatient As Integer,
strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim dbs As Database, rst As Recordset
Dim strname As String
Set dbs = CurrentDb()
' Create dynaset-type Recordset object.
Set rst = dbs.OpenRecordset("qryfrmNewPatient", dbOpenDynaset)
strname = [LastName] & ", " & [FirstName]
rst.FindFirst "Patientname = '" & strname & "'"
If rst.NoMatch Then
Exit Sub
Else
strStaff = DLookup("StaffAssigned",
"qryFindaMatch", "[PatientName] =" & _
"[Forms]![frmNewPatient]![PatientName]")
dteBirthDate = DLookup("DateOfBirth",
"qryFindaMatch", "[PatientName] ='" & strname & "'")
Msg = " The Patient: " & strname & vbCrLf &
vbCrLf & " Was Assigned to: " & _
" <" & strStaff & ">" & vbCrLf & vbCrLf & _
"Date Of Birth: " & dteBirthDate & vbCrLf &
vbCrLf & _
"This patient already exist! Please verify
this patient from the blue box"
Style = vbYes + vbInformation +
vbDefaultButton1
Title = "Find An Assigned Staff Name"
Response = MsgBox(Msg, Style, Title)
Me.Undo
Me!LookUp.Requery
Me!MatchStaff.Requery
Me.Requery
End If
rst.Close
Set dbs = Nothing
Me.Refresh
*******************************************end
can some one help with may be a better code?
what I need is to compare the names entered to the names in the database.
one problem is that I would like to account for hyphens and accents.
thanks
Al
takes names of clients as they come. I want to check after the user enters
the first and last name if the name exist in the data base, if it does it
should alert the data entry person. I am using the following code which all
of the sudden stoped functioning the way it should, i.e. there are similar
name that the code missed:
start********************************
Dim strStaff As String, dteBirthDate As String,intMatchpatient As Integer,
strCriteria As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim dbs As Database, rst As Recordset
Dim strname As String
Set dbs = CurrentDb()
' Create dynaset-type Recordset object.
Set rst = dbs.OpenRecordset("qryfrmNewPatient", dbOpenDynaset)
strname = [LastName] & ", " & [FirstName]
rst.FindFirst "Patientname = '" & strname & "'"
If rst.NoMatch Then
Exit Sub
Else
strStaff = DLookup("StaffAssigned",
"qryFindaMatch", "[PatientName] =" & _
"[Forms]![frmNewPatient]![PatientName]")
dteBirthDate = DLookup("DateOfBirth",
"qryFindaMatch", "[PatientName] ='" & strname & "'")
Msg = " The Patient: " & strname & vbCrLf &
vbCrLf & " Was Assigned to: " & _
" <" & strStaff & ">" & vbCrLf & vbCrLf & _
"Date Of Birth: " & dteBirthDate & vbCrLf &
vbCrLf & _
"This patient already exist! Please verify
this patient from the blue box"
Style = vbYes + vbInformation +
vbDefaultButton1
Title = "Find An Assigned Staff Name"
Response = MsgBox(Msg, Style, Title)
Me.Undo
Me!LookUp.Requery
Me!MatchStaff.Requery
Me.Requery
End If
rst.Close
Set dbs = Nothing
Me.Refresh
*******************************************end
can some one help with may be a better code?
what I need is to compare the names entered to the names in the database.
one problem is that I would like to account for hyphens and accents.
thanks
Al