Mon problème est que je n'arrive pas à faire afficher automatiquement le cumul des heures pour les nouveaux matricules.
Normalement quand je sélectionne le matricule sur le comboBox, le nom, le prénom, la CIN s'affiche automatiquement, aussi les labels affecté aux cumuls devraient eux aussi afficher automatiquement les cumuls du nouveau matricule, c'est à dire 0 ( ici, il s'agit des heures 00:00:00 )
Au lieu de ça, le VB6 me renvoie le message ( Erreur d'exécution '94' Utilisation non autorisé de NULL )
Pour vous permettre de comprendre mon cas, voilà mes codes.
Si je n'arrive pas à les bien exposer, excusez moi, car je ne suis qu'un apprenti à ses débuts.
Merci pour votre aide. Vos remarques et vos critiques sont les bienvenus.
Vos corrections seront mieux encore.
Private Sub Form_Load()
PoolConnection
SQLs = "select * from TableauInfo"
If RS.State = adStateOpen Then RS.Close
RS.Open SQLs, DB, adOpenKeyset, adLockPessimistic
'-----------------------------------------------------
Do Until RS.EOF
cmbMatricule.AddItem (RS![MATRICULE])
RS.MoveNext
Loop
End Sub
Private Sub cmbHSorApm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If cmbHSorApm = "" Then
MsgBox "Veuillez sélectionner l'heure de sortie", vbCritical + vbMsgBoxRight, "Erreur"
cmbHSorApm.SetFocus
Exit Sub
End If
'-----------------------------------------------------
Dim x As Date
x = CDate(cmbHSorApm) - CDate(cmbHEntApm)
lblTHnApm.Caption = x
cmbHEntSup.SetFocus
'----------------------------------------------------
Dim Total1HnM As Date
Dim Total2HnApm As Date
Dim TotalHnJ As Date
Dim Xx As Date
Total1HnM = CDate(lblTHnM)
Total2HnApm = CDate(lblTHnApm)
TotalHnJ = Total1HnM + Total2HnApm
Xx = TotalHnJ
lblTHnJ.Caption = Xx
Dim Total1HnM As Date
Dim Total2HnApm As Date
Dim TotalHnJ As Date
Dim Xx As Date
Total1HnM = CDate(lblTHnM)
Total2HnApm = CDate(lblTHnApm)
TotalHnJ = Total1HnM + Total2HnApm
Xx = TotalHnJ
lblTHnJ.Caption = Xx
'-----------------------------------------------------------------------------
RS.Open
Dim XCumul1Hn As Date
Dim y As Date
XCumul1Hn = RS![CumulHn]
y = XCumul1Hn + CDate(lblTHnJ.Caption)
lblCumulHn.Caption = y
RS.Close
End If
End Sub
Private Sub cmbMatricule_KeyPress(KeyAscii As Integer)
Dim Z
If KeyAscii = 13 Then
If cmbMatricule = "" Then
MsgBox "Veuillez selectionner le Matricule", vbCritical + vbMsgBoxRight, "Erreur"
cmbMatricule.SetFocus
Exit Sub
End If
Z = CLng(cmbMatricule)
SQLs = " select * from TableauInfo where MATRICULE='" & CLng(cmbMatricule) & "'"
If RS.State = adStateOpen Then RS.Close
RS.Open SQLs, DB, adOpenKeyset, adLockPessimistic
If KeyAscii = 13 Then
If RS.EOF And RS.BOF Then
MsgBox "Ce Matricule n'existe pas", vbCritical + vbMsgBoxRight, "Erreur"
Exit Sub
cmbMatricule.SetFocus
Else
RS.MoveFirst
TCin = RS![CIN]
TNom = RS![NOM]
TPrenom = RS![PRENOM]
lblCumulHn.Caption = RS![CumulHn]
lblCumulHSup.Caption = RS![CUMULHSUP]
lblCumulHAlatache.Caption = RS![CUMULHALATACHE]
End If
RS.Close
End If
cmbHEntM.SetFocus
End If
c148270
Messages postés303Date d'inscriptionmercredi 12 janvier 2005StatutMembreDernière intervention 3 octobre 20131 15 avril 2013 à 09:59
Bonjour
En faisant du pas à pas tu trouveras quel est le champ incriminé.
Regarde la définition des champs de la table il doit y en avoir un (ou plusieurs avec la mention nul autorisé : non