superfri
Messages postés10Date d'inscriptionlundi 11 décembre 2006StatutMembreDernière intervention30 septembre 2011
-
25 oct. 2009 à 11:56
jmf0
Messages postés1566Date d'inscriptionmardi 26 décembre 2000StatutMembreDernière intervention 5 avril 2013
-
25 oct. 2009 à 19:45
bjr j'ai un code qui m'exécute deux fois la boite de dialoque et je ne comprend pas pourquoi? prière de m'aide. je vous donne tout le code d'un formulaire.
If Adodc1.Recordset.BOF True And Adodc1.Recordset.EOF True Then
MsgBox ("pas de cause probable enregistrée"), vbOKOnly
Else
rtextbCode.Text = Adodc1.Recordset!codecp
rtxtbLibelle.Text = Adodc1.Recordset!LibelleCP
End If
handler:
For Each adoer In cnn.Errors
MsgBox adoer.Description
Next
End Sub
'chargement de la liste
Adodc1.ConnectionString = cnn.ConnectionString
Adodc1.RecordSource = "select Codecp, Libellecp from causeprobable order by Codecp asc"
Set DataGrid1.DataSource = Adodc1
'fin chargement
End Sub
Private Sub reycomenre_Click()
If rtextbCode.Text = "" Then
MsgBox "ce champ code ne doit pas être vide"
rtextbCode.SetFocus
reycomenre.Enabled = False
Exit Sub
End If
If rtxtbLibelle.Text = "" Then
MsgBox "ce champ ne doit pas être vide"
rtxtbLibelle.SetFocus
reycomenre.Enabled = False
Exit Sub
End If
If Len(rtextbCode.Text) <> 4 Then
MsgBox "ce champ prend 4 caractères!!!!", vbCritical
rtextbCode.SetFocus
reycomenre.Enabled = False
Exit Sub
End If
If Len(rtxtbLibelle.Text) > 50 Then
MsgBox "ce champ doit contenir au plus 50 caractères exclusivement!!!!"
reycommodifier.Enabled = False
Exit Sub
End If
Set rsado1 = New Recordset
rsado1.Open "select * from causeprobable where codecp='" & rtextbCode.Text & "' or Libellecp = '" & DoubleQuote(rtxtbLibelle.Text) & "'", cnn, adOpenStatic, adLockOptimistic
If rsado1.RecordCount <> 0 Then
MsgBox "Vérifier code ou libellé !", vbCritical
Exit Sub
End If
'lors de l'enregistrement cette partie en rouge s'affiche encore après la partie en vert en bas
If rtextbCode.Text = "" Then
MsgBox "ce champ code ne doit pas être vide"
rtextbCode.SetFocus
reycommodifier.Enabled = False
Exit Sub
End If
If rtxtbLibelle.Text = "" Then
MsgBox "ce champ ne doit pas être vide"
rtxtbLibelle.SetFocus
reycommodifier.Enabled = False
Exit Sub
End If
Set rsado1 = New Recordset
rsado1.Open "update causeprobable set libellecp= '" & LCase(DoubleQuote(rtxtbLibelle.Text)) & "' where codecp='" & rtextbCode.Text & "'", cnn, adOpenDynamic, adLockOptimistic
MsgBox "Opération effectué !", vbInformation
lors de la modification la partie en bleu s'exécute deux fois
Adodc1.Refresh
reycommodifier.Enabled = False
rtextbCode.Text = ""
rtxtbLibelle.Text = ""
End Sub
Private Sub reycomnouveau_Click()
rtextbCode.Text = ""
rtxtbLibelle.Text = ""
rtextbCode.Enabled = True
compte
End Sub
Private Sub reycomquitter_click()
Unload Me
End Sub
Private Sub rtxtbLibelle_Change()
reycomenre.Enabled = True
If rtxtbLibelle.Text = "" Then
reycomenre.Enabled = False
End If
If IsNumeric(rtxtbLibelle.Text) Then
MsgBox "ce champ n'est pas numérique", vbOKOnly
rtxtbLibelle.SetFocus
End If
End Sub
Private Sub compte()
Set rsado1 = New Recordset
rsado1.Open "select * from causeprobable", cnn, adOpenStatic, adLockReadOnly
With rsado1
If .RecordCount = 0 Then
rtextbCode.Text = "B.01"
Else
str1 = .RecordCount + 1
If str1 < 10 Then
str = "B.0"
rtextbCode.Text = str & str1
Else
If str1 >= 10 Then
str = "B."
rtextbCode.Text = str & str1
End If
End If
End If
End With
End Sub
merci pour votre bonne compréhension et votre promptitude.
superfri
Messages postés10Date d'inscriptionlundi 11 décembre 2006StatutMembreDernière intervention30 septembre 2011 25 oct. 2009 à 19:37
merci jmf0; mon soucis n'est pas de créé d'ambiguité mais de donné toutes les informations nécessaire pour une éventuelle résolution.
l'endroit des erreurs est coloré.
jmf0
Messages postés1566Date d'inscriptionmardi 26 décembre 2000StatutMembreDernière intervention 5 avril 20138 25 oct. 2009 à 19:43
Je te le répète donc : un code non indenté et non mis en forme me donne le tournis (et ce n'est pas conseillé, ni à mon âge, ni à des âges moins avancés que le mien...)
Je le regarderai lorsqu'il sera devenu suffisamment lisible sans maux de crâne ...
Tu voudras bien comprendre qu'il est naturel de préserver sa santé, hein ...
jmf0
Messages postés1566Date d'inscriptionmardi 26 décembre 2000StatutMembreDernière intervention 5 avril 20138 25 oct. 2009 à 19:45
ouvre d'autres discussions ouvertes et contenant du code VB.... !
Regarde donc comment est présenté un code.
Fais-en autant, s'il te plait !
Tu as pour cela, si ton code originel est indenté, à utiliser les balises code, présentes dans la barre d'outil de ta discussion.