salim0shark
Messages postés31Date d'inscriptionmardi 11 mars 2008StatutMembreDernière intervention 3 novembre 2014
-
22 avril 2008 à 09:50
salim0shark
Messages postés31Date d'inscriptionmardi 11 mars 2008StatutMembreDernière intervention 3 novembre 2014
-
22 avril 2008 à 10:52
slt a tous
voila je travaille sur un projet de Gestion de vidéotheque mais le probleme c'est que j'ai prevu une (frmCommande) danslaquelle l'utilisateur doit donner la (reférence Clt) dans (lblnum.text) et appuyer sur le boutton VALIDER N°CLT
normalement j'ai ajouter dans ma frmCommande une Adodc1 connecté a ma table Clients j'arrive mnt a récupérer la ref client et a l'afficher mais maintenant lorsque j'ai ajouté le cas danslequel il se peut que la refclient saisie par l'utilisateur n'est pas valide alors (maintenant meme si j'entre une refclt valide le message(MsgBox("Le client " & lblnum.Text & " n'existe pas. Voulez vous
enregistrer un nouveau client ?", vbYesNo + vbInformation,
"Attention...")
aidez moi et merci d'avance
Private Sub cmdCltValider_Click()
Dim Rep As String
Dim marequete As String
If lblnum.Text = "" Then
Rep = MsgBox("Veuillez rentrer le numero du client.", vbInformation, "Attention...")
Exit Sub
End If
marequete = "SELECT * FROM Clients WHERE Refclient LIKE '" & lblnum.Text & "'"
If Not Adodc1.Recordset.EOF Then
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = marequete
Adodc1.Refresh
lblnom.Caption = Adodc1.Recordset![Nom]
lblprenom.Caption = Adodc1.Recordset![Prenom]
lbladresse.Caption = Adodc1.Recordset![Adresse]
lbltel.Caption = Adodc1.Recordset![Téléphone]
Else:
Rep = MsgBox("Le client " & lblnum.Text & " n'existe pas. Voulez vous enregistrer un nouveau client ?", vbYesNo + vbInformation, "Attention...")
If Rep = vbYes Then
frmCommande.Hide
frmClient.Show
Exit Sub
End If
End If
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 22 avril 2008 à 10:31
vbYesNo + vbInformation
prends l'habitude de combiner ces flags avec un Or :
vbYesNo Or vbInformation
enfin, le titre de tes MsgBox n'est pas très parlant. mets y l'information condensée, ca aide a ne pas lire les MsgBox... ou a mieux les comprendre ... ex: "Créer nouveau client ?"
une fois nettoyé:
Private Sub cmdCltValider_Click()
If lblnum.Text = "" Then
MsgBox "Veuillez rentrer le numero du client.", vbInformation, "N° de client non saisi."
Else
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT `Nom`, `Prénom`, `Adresse`, `Téléphone` " & _
"FROM `Clients` WHERE `Refclient`='" & lblnum.Text & "' "
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
lblnom.Caption = Adodc1.Recordset![Nom]
lblprenom.Caption = Adodc1.Recordset![Prenom]
lbladresse.Caption = Adodc1.Recordset![Adresse]
lbltel.Caption = Adodc1.Recordset![Téléphone]
ElseIf vbYes = MsgBox("Le client " & lblnum.Text & " n'existe pas." & vbnewline & _
"Voulez vous enregistrer un nouveau client ?", vbYesNo + vbInformation, "Créer nouveau client ?")
frmCommande.Hide
frmClient.Show
End If
End If
End Sub
salim0shark
Messages postés31Date d'inscriptionmardi 11 mars 2008StatutMembreDernière intervention 3 novembre 2014 22 avril 2008 à 10:52
merciiiiiiiiiiiiiiiii infinimenttttttttt
et pour mes msgbox je crois que vous avez raison
j'essairais d'en faire plus de signification la prochaine fois
encore merci