1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Sub test04()
Dim numero, myMsg, adr
numero = InputBox("Donnez le numéro client ", "Données", 123456)
'introduire ici quelques instructions pour valider l'encodage, au cas où
'l'utilisateur introduit autre chose qu'un numéro. Prévoir aussi une sortie
'si l'on veut annuler l'encodage.
NomClient = DLookup("[NomClientDansTaTable]", "[NomDeTaTable]", "[NumClientDansTaTable]=" & numero)
'Attention: la fonction inputbox renvoie du texte, donc si [NumClientDansTaTable] est numérique,
'il faudra remplacer 'numéro' dans l'égalité ci-dessus par cLng(numero) ou Val(numero), ....
myMsg = "Le client choisi est : "
MsgBox myMsg & NomClient, vbOKOnly, "Résultat"
'si vous avez d'autres infos à afficher, l'adresse par exemple:
adr = DLookup("[adresseClt]", "[NomDeTaTable]", "[NumClientDansTaTable]=" & numero)
myMsg = myMsg & NomClient & vbLf & vbLf & adr
MsgBox myMsg, vbOKOnly, "Résultat"
End Sub |
Partager