ngalino
Messages postés65Date d'inscriptionsamedi 21 avril 2007StatutMembreDernière intervention15 octobre 2009
-
25 juil. 2008 à 20:20
LIBRE_MAX
Messages postés1402Date d'inscriptionmardi 1 mai 2007StatutMembreDernière intervention 7 octobre 2012
-
26 juil. 2008 à 16:33
bonsoir,
j'ai un formulaire auquel j'associe un ensemble de contrôles. En effet, il ya deux Textbox: textbox1 qui affiche le numero de ligne et textbox2 le numero de folio (un folio est un ensemble de ligne; 99 par exemple). Ainsi, j'ai besoin que ses numeros s'affichent automatiquement à l'ouverture du formulaire et à chaque fois qu'un enregistrement est ajouté dans la table.
Voici les fonctions porposées à cet effet:
Private Function AjouterLigne() As Integer
Dim rst As New ADODB.Recordset
Dim nl As Integer
rst.Open "ecriture", connectionStringBDD, , , adCmdTable
If rst.BOF And rst.EOF Then
AjouterLigne = 1
End If
If Not rst.EOF Then
rst.MoveLast
If rst!Ligne < 99 Then
nl = nl + 1
End If
If rst!Ligne = 99 Then
nl = 1
End If
AjouterLigne = nl
End If
rst.Close
End Function
Private Function AjouterFolio() As Integer
Dim rst As New ADODB.Recordset
Dim nf As Integer
rst.Open "ecriture", connectionStringBDD, , , adCmdTable
If rst.BOF And rst.EOF Then
AjouterFolio = 1
End If
If Not rst.EOF Then
rst.MoveLast
If rst!Ligne < 99 Then
nf = nf
End If
If rst!Ligne = 99 Then
nf = nf + 1
End If
AjouterFolio = nf
End If
rst.Close
End Function
Private sub Form_Load()
txtLigne.Text=AjouterLigne
txtFolio.Text=AjouterFolio
End Sub
merci de l'observer et me faire parvenir vos suggestions svp.
ngalino
Messages postés65Date d'inscriptionsamedi 21 avril 2007StatutMembreDernière intervention15 octobre 2009 26 juil. 2008 à 11:34
merci pour ta participation. cependant je pense qu'une erreur s'est glissée quelque part, parce que à mon avis rst.close et set rst= nothing ne doivent pas être là. en effet, quand on fait rst.open , c'est rst.close qu'on emploie et quand c'est set rst =cmd.execute par exemple, là alors on utilise set rst=nothing.