|
-
Jan 5th, 2000, 03:12 AM
#3
Junior Member
Hi passmaster16'
The following code works for me! it can easily be adapted to any field in the Access Database.
Private Sub SearchCmd_Click()
Dim mybkmark As Variant
GlobalFound = "Yes"
' Unload CaseScr
' Unload PartScr
Do While True
'Set a bookmark to the current record.
mybkmark = datPrimaryRS.Recordset.Bookmark
strLastName = LastNameSrchText.Text
strPatIDNo = MedRecSrchText.Text
' can't Enter Both
If strLastName <> "" And strPatIDNo <> "" Then
MsgBox "Can't Enter Both Medical Record Number And Last Name", vbOKCancel
Exit Sub
End If
' both Can't Be Blank
If strLastName = "" And strPatIDNo = "" Then
MsgBox "Can't Search Must Have Either Last Name Or Medical Record Number To Search"
Exit Sub
End If
' If strSearch = "" Then Exit Do ' If No Value Exit!
If strLastName <> "" Then
'Search forward for the CustomerID
datPrimaryRS.Recordset.Find "LastName = '" & strLastName & "'", 0, adSearchForward
'If the record isn't found, we will be at the end of the recordset.
'So, reposition the recordset back to the record we came from and search backwards.
If datPrimaryRS.Recordset.EOF Then
datPrimaryRS.Recordset.Bookmark = mybkmark
datPrimaryRS.Recordset.Find "LastName = '" & strLastName & "'", 0, adSearchBackward
'If we don't find the record this time, it doesn't exist.
'So, reposition the recordset back to the record we came from and tell the user.
If datPrimaryRS.Recordset.BOF Then
datPrimaryRS.Recordset.Bookmark = mybkmark
MsgBox "Record Not Found"
End If
End If
End If
If strPatIDNo <> "" Then
'Search forward for the CustomerID
datPrimaryRS.Recordset.Find "PatientID = '" & strPatIDNo & "'", 0, adSearchForward
'If the record isn't found, we will be at the end of the recordset.
'So, reposition the recordset back to the record we came from and search backwards.
If datPrimaryRS.Recordset.EOF Then
datPrimaryRS.Recordset.Bookmark = mybkmark
datPrimaryRS.Recordset.Find "PatientID = '" & strPatIDNo & "'", 0, adSearchBackward
'If we don't find the record this time, it doesn't exist.
'So, reposition the recordset back to the record we came from and tell the user.
If datPrimaryRS.Recordset.BOF Then
datPrimaryRS.Recordset.Bookmark = mybkmark
MsgBox "Record Not Found"
End If
End If
End If
' Get The Cases Assigned and Load a Combo Box
EncounterCboBox_Load (txtFields(0).Text)
Exit Do
Loop
EnableTextBoxes ' Let Them change The record
' Clear The Search boxes
MedRecSrchText.Text = ""
LastNameSrchText.Text = ""
Exit Sub
AddErr:
MsgBox "Data Error"
End Sub
datPrimaryRS is an ADO Recordset. I got the basis of this code from a Microsoft tech. You'd think they would have something like this in their Illustrous MSDN online wouldn't you. I had to open a problem notification.
Hope this helps let me know.
JimB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|