spamito
Messages postés183Date d'inscriptionsamedi 24 mars 2007StatutMembreDernière intervention30 mars 2013
-
2 oct. 2008 à 23:18
spamito
Messages postés183Date d'inscriptionsamedi 24 mars 2007StatutMembreDernière intervention30 mars 2013
-
3 oct. 2008 à 11:56
Salut,
Je veux réaliser un compteur des enregistrements mais j'ai un problème avec, voici mon code :
conn = New Connection
With conn
.Provider = "Microsoft.Jet.oledb.4.0"
.Open("data source=" & Application.StartupPath & "\BASE\BASE.mdb")
End With
rs = New Recordset
With rs
.ActiveConnection = conn
.Open("SELECT Demandes.N_demande FROM Demandes", , CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockPessimistic)
End With
If rs.EOF Then
ndemande.Text = Format(Now, "yyyy/MM/dd") & "/" & 1
Else
ndemande.Text = Format(Now, "yyyy/MM/dd") & "/" & rs.RecordCount + 1
End If
Quand la table est vide, tout marche très bien, mais quand je la rempli avec un seul enregistrement je reçoi ce résultat : "2008/10/02/0". Quelqu'un pourrait-il m'expliquer pourquoi ?
spamito
Messages postés183Date d'inscriptionsamedi 24 mars 2007StatutMembreDernière intervention30 mars 2013 3 oct. 2008 à 11:56
Bon voici la solution :
conn = New Connection
With conn
.Provider = "Microsoft.Jet.oledb.4.0"
.Open("data source=" & Application.StartupPath & "\BASE\BASE.mdb")
End With
rs = New Recordset
With rs
.ActiveConnection = conn
.CursorLocation = CursorLocationEnum.adUseClient
.Open("SELECT Demandes.N_demande FROM Demandes", , CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)
End With
If rs.EOF Then
ndemande.Text = Format(Now, "yyyy/MM/dd") & "/" & 1
Else
ndemande.Text = Format(Now, "yyyy/MM/dd") & "/" & rs.RecordCount + 1
End If
Il fallait juste ajouter la ligne " .CursorLocation = CursorLocationEnum.adUseClient" que j'ai oublié de la mettre.
Merci Casy pour ton soutien.