1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Dim NomRecherche As String
Dim PrenomRecherche As String
Dim Matable As DataTable
Matable = DS_cabinet.Tables("_tbPATIENT")
'cree un objet dataview pour filtrer les enregistrements
Dim filtre As New DataView(Matable)
Dim CountItem As Integer
NomRecherche = InputBox("Veuillez entrer le nom recherché", "Recherche")
PrenomRecherche = InputBox("Veuillez entrer le prénom recherché", "Recherche")
If NomRecherche = "" And PrenomRecherche = "" Then
MsgBox("veuillez entrer un nom et/ou un prénom à rechercher SVP")
'definition de notre table
Else
If NomRecherche = "" Then
filtre.RowFilter = "prenom like'*"& PrenomRecherche & "*'"
ElseIf PrenomRecherche = "" Then
filtre.RowFilter = "nom like'*"& NomRecherche & "*'"
Else
filtre.RowFilter = "nom like'*"& NomRecherche & "*' AND prenom like'*"& PrenomRecherche & "*'"
End If
CountItem = filtre.Count
End If
If CountItem > 0 Then
txt_id.Text = filtre.Item(0)(0)
txt_nom.Text = filtre.Item(0)(1)
txt_prenom.Text = filtre.Item(0)(2)
txt_s.Text = filtre.Item(0)(3)
txt_a.Text = filtre.Item(0)(4)
txt_p.Text = filtre.Item(0)(5)
txt_adr.Text = filtre.Item(0)(6)
txt_tel.Text = filtre.Item(0)(7)
txt_m.Text = filtre.Item(0)(8)
Else : MsgBox("Inexistant")
End If
End Sub |
Partager