noycez Level: VB Guru

 Registered: 14-10-2002 Posts: 79
|
Re: Searching
Private Sub cmdSearch_Click()
With mRec
If .RecordCount <> 0 Then
'move next if not End of File
If Not .EOF Then
.MoveNext
Else
.MoveFirst
End If
'take note of the '*', this is a wildcharacter
'so that is you search 'Mag' it will search all records that has a 'Mag' on it
.Find "Name like *" & Trim(txtSearch.Text) & "*"
If Not .EOF Then
MsgBox !Name & " found in the database", vbInformation, "Record Found"
txtSearch.SetFocus
Else
'search again from the beggining of the recordset
.MoveFirst
.Find "Name like *" & Trim(txtSearch.Text) & "*"
If Not .EOF Then
MsgBox !Name & " found in the database", vbInformation, "Record Found"
txtSearch.SetFocus
Else
MsgBox "Record not found in the database", vbInformation, "Record Not Found"
txtSearch.Text = vbNullString
End If
End If
Else
MsgBox "There is no record to be searched", vbInformation, "No Record"
txtSearch.Text = vbNullString
End If
End With
End Sub
....the double-clicking stuff is not included in the code, i think you can do it on your own 
____________________________
Funny thought:
Practice makes perfect.....
But nobody's perfect......
so why practice?
|