Fin ou début de table access

Résolu
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007 - 7 juin 2006 à 08:27
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007 - 7 juin 2006 à 10:21
Bonjour,

J'aurais besoin de savoir quel propriété je doit utilisé pour tester si je suis à la fin ou au début de ma table.

J'ais bien essayer d'utilisé recordset.EOF et recordset.BOF mais c'est sans succé.

Merci à tous.

8 réponses

thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 10:21
Et bien voila je me suis débrouillé comm eun chef, je vous donne le code des deux bouttons pour ceux qui en aurais besoin :

Private Sub Command1_Click()
Do While rPrecedant.BOF = True
  rPrecedant.MovePrevious
  If rPrecedant.BOF = True Then
    rPrecedant.MoveNext
    Exit Do
  End If
Loop
rPrecedant.MoveNext
If rPrecedant.EOF = True Then
  MsgBox "Plus d'enregistrement précédant"
  rPrecedant.MoveFirst
  Command1.Visible = False
  Command3.Visible = True
  Exit Sub
End If
Text4.Text = rPrecedant.Fields!Date
Text5.Text = rPrecedant.Fields!NumOf
Text6.Text = Format((rPrecedant.Fields!Compteur), "# ##0")
Text7.Text = rPrecedant.Fields!Format
End Sub

et

Private Sub Command3_Click()
Do While rSuivant.BOF
  rSuivant.MovePrevious
  If rSuivant.BOF = True Then
    rSuivant.MoveNext
    Exit Do
  End If
Loop
rSuivant.MoveNext
If rSuivant.EOF Then
  MsgBox "Plus d'enregistrement suivant"
  rSuivant.MoveFirst
  Command3.Visible = False
  Command1.Visible = True
  Exit Sub
End If
Text4.Text = rSuivant.Fields!Date
Text5.Text = rSuivant.Fields!NumOf
Text6.Text = Format((rSuivant.Fields!Compteur), "# ##0")
Text7.Text = rSuivant.Fields!Format
End Sub

Bonne chance à tous.
3
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
7 juin 2006 à 08:44
EOF correspond à "EndOfFile", c'est à dire que tu te trouve après le dernier enregistrement.
BOF correspond à "BeginOfFile", c'est à dire que tu te trouve avant le premier enregistrement.

Pour tester si tu es sur le premier ou le dernier, il faut d'abord de déplacer (soit en avant soit en arrière) puis tester l'EOF ou le BOF selon le cas, et revenir à la position d'origine.

_
Avant de poster dans le forum,
prière d'aller lire ceci :
http://www.codes-sources.com/reglement.aspx
<s></s>
0
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 09:05
hum hum en effet je suis d'accord....

Le plus simple c'est que je te donne mon code enfin je pense !!

Private Sub Command1_Click()
If Not rSuivPre.BOF Then     
  rSuivPre.MoveLast                  'Correctement effectuer
End If
If rSuivPre.BOF Then               'Condition que je ne trouve pas
  MsgBox "Plus d'enregistrement précédant"
  Command1.Visible = False
  Command3.Visible = True
  Exit Sub
Else
  rSuivPre.MovePrevious            
  Text4.Text = rSuivPre.Fields!Date
  Text5.Text = rSuivPre.Fields!NumOf
  Text6.Text = Format((rSuivPre.Fields!Compteur), "# ##0")
  Text7.Text = rSuivPre.Fields!Format
End If
0
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 09:15
bon j'ais repensé tout ca et j'ais fait comme cela !!

Private Sub Form_Load()
Set rSuivant = bd.OpenRecordset("SELECT * FROM CompteurRebuts ORDER BY Date ASC", dbOpenDynaset)
Set rPrecedant = bd.OpenRecordset("SELECT * FROM CompteurRebuts ORDER BY Date DESC", dbOpenDynaset)
End Sub
Private Sub Command1_Click()
If Not rPrecedant.BOF Then
  rPrecedant.MoveFirst
End If
If rPrecedant.EOF Then
  MsgBox "Plus d'enregistrement précédant"
  Command1.Visible = False
  Command3.Visible = True
  Exit Sub
Else
  rPrecedant.MoveNext
  Text4.Text = rPrecedant.Fields!Date
  Text5.Text = rPrecedant.Fields!NumOf
  Text6.Text = Format((rPrecedant.Fields!Compteur), "# ##0")
  Text7.Text = rPrecedant.Fields!Format
End If
End Sub

mon déplacement est correct mais il n'arrive jamais à la fin de rPrecedant
idem pour rSuivant
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 09:55
La je galère vraiment si tu pe me détailé la méthode ca serrai simpas.

Merci.
0
billoute 50 Messages postés 76 Date d'inscription lundi 20 mars 2006 Statut Membre Dernière intervention 30 octobre 2007 2
7 juin 2006 à 09:56
Salut moi je pense que tu devrai faire comme te la dit DARKSIDIOUS


Dans ta commande enregistrement précédent:


rprecedent.moveprevious
if rprecedent.BOF then
   rprecedent.movefirst
   msgbox("plus d'enregistrement!")
end if


Ou alors tu peut essayer de jouer avec les index


 


 
0
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 10:01
Yééééééééé j'ais trouvé............

Private Sub Command1_Click()
Do While rPrecedant.BOF
  rPrecedant.MovePrevious
  If rPrecedant.BOF = True Then
    rPrecedant.MoveNext
    Exit Do
  End If
Loop
rPrecedant.MoveNext
If rPrecedant.EOF Then
  MsgBox "Plus d'enregistrement précédant"
  Command1.Visible = False
  Command3.Visible = True
  Exit Sub
End If
Text4.Text = rPrecedant.Fields!Date
Text5.Text = rPrecedant.Fields!NumOf
Text6.Text = Format((rPrecedant.Fields!Compteur), "# ##0")
Text7.Text = rPrecedant.Fields!Format
End Sub

Et ca marche niquel merci encore pour ton aide et bonne journée.
0
thkiller Messages postés 168 Date d'inscription mercredi 24 mai 2006 Statut Membre Dernière intervention 11 septembre 2007
7 juin 2006 à 10:05
Enfin ca marche pour le précedant mais pas pour le suivant je vais voir ce que je pe faire !! lol
0
Rejoignez-nous