1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Sub btnChercher_Click()
Dim vCherche As Variant
vCherche = Nz(Me.txtRecherche, "*")
' on vide le champ de recherche
Me.txtRecherche = ""
' se positionne sur le premier champ de recherche
Me.Adresse.SetFocus
' mémorisation du n° d'enregistrement
lCurrentRecord = Me.CurrentRecord
DoCmd.FindRecord "*" & vCherche & "*", , , acSearchAll, , , False
' si la recherche n'a pas abouti, on retourne au début de la table
If Me.CurrentRecord = lCurrentRecord Then
DoCmd.GoToRecord acDataForm, Me.Name, acFirst
DoCmd.FindRecord "*" & vCherche & "*", , , acSearchAll, , , False
End If
' on restaure le champ de recherche
Me.txtRecherche = vCherche
End Sub |
Partager