IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Requêtes et SQL. Discussion :

récupération enregsitrement précedent


Sujet :

Requêtes et SQL.

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 264
    Points : 108
    Points
    108
    Par défaut récupération enregsitrement précedent
    Bonjour,
    dans une table, j'ai les données sous la forme suivantes :

    site A - date - elm1 - elm2 - elm3 - elm4- elm5-elm6 elm1 -elm7 -elm1

    paris 12/02/2004 - xxx- xxx- xxx- xxx- xxx- xxx- xxx- xxx- xxx-

    lille 10/02/2001 - yyy- yyy- yyy- yyy- yyy- yyy- yyy- yyy-yyy-

    Dans un form je recupere cette valeur avec en selection la ville et la date.Ce sont des listes modifiables.
    Par exemple dans mon form, j'ai les infos de Paris , 12/02/2004 avec dans mes zones de textes tous les champs xxx.
    Maintenant avec un bouton je veux modifier les valeurs actuelles qui sont affichées via mon form. Par exemple je veux modifier uniquement le champ elm3 de Paris en mettant non plus xxx mais zzz avec une nouvelle date 29/05/08 mais je veux garder les mêmes valeurs pour les autres champs donc en fait je veux crée dans ma table un nouvel enregistrement pour avoir en fait tous les champs non modifiés sont copiés dans le nouvel enregistrement sauf elm3 qui est changé.

    site A - date - elm1 - elm2 - elm3 - elm4- elm5-elm6 elm1 -elm7 -elm1

    paris 12/02/2004 - xxx- xxx- xxx- xxx- xxx- xxx- xxx- xxx- xxx-

    lille 10/02/2001 - yyy- yyy- yyy- yyy- yyy- yyy- yyy- yyy-yyy-

    paris 29/05/08 - xxx- xxx- yyy- xxx- xxx- xxx- xxx- xxx- xxx-

    Voici le code essayé mais ca ne marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
     :
     
    Function MAJ_BaseAffaire(oform As Form)
     
     
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim oControl As Control
    Dim i As String
    Dim j As Integer
     
    Dim tampon As Variant
     
     
     
           Set db = CurrentDb
           Set rs = db.OpenRecordset("Référence LOC", dbOpenDynaset)
           'i = UCase(Forms![référence]![liste1])
           sSQL = "Select * From [Référence LOC]  WHERE [LOC]= '" & i & "'  ;"
           Set rs = db.OpenRecordset(sSQL)
          ' order by [Référence LOC].[Date de Réference] DESC
     
     
        rs.AddNew
     
        rs![Loc] = oform.liste1
     
        rs![Date de Réference] = oform.Texte108.Value
     
        rs![Axe long E1] = oform.Axe_long_E1.Value
        rs![Axe1 E1] = oform.Axe1_E1.Value
        rs![Axe2 E1] = oform.Axe2_E1.Value
        rs![ML long E1] = oform.ML_E1.Value
     
     
       rs![Axe long E2] = oform.Axe_long_E2.Value
       rs![Axe court E1] = oform.Axe1_E2.Value
       rs![Axe2 court E1] = oform.Axe2_E2.Value
       rs![ML E2] = oform.ML_E2.Value
     
       rs![Axe court E1] = oform.Axe_court_E1.Value
       rs![Axe1 court E1] = oform.Axe1_court_E1.Value
       rs![Axe2 court E1] = oform.Axe2_court_E1.Value
       rs![ML court E1] = oform.ML_court_E1.Value
     
       rs![Axe court E2] = oform.Axe_court_E2.Value
       rs![Axe1 court E2] = oform.Axe1_court_E2.Value
       rs![Axe2 court E2] = oform.Axe2_court_E2.Value
       rs![ML court E2] = oform.ML_court_E2.Value
     
       rs![Espace 90 E1] = oform.DDM_90_E1.Value
       rs![Espace 150 E1] = oform.DDM_150_E1.Value
       rs![Fsc1 E1] = oform.Fsc1_E1.Value
       rs![Fsc2 E1] = oform.Fsc2_E1.Value
     
       rs![Espace 90 E2] = oform.DDM_90_E2.Value
       rs![Espace 150 E2] = oform.DDM_150_E2.Value
       rs![Fsc1 E2] = oform.Fsc1_E2.Value
       rs![Fsc2 E2] = oform.Fsc2_E2.Value
     
       rs![Clr 1 E1] = oform.Clr_1_E1.Value
       rs![Clr 2 E1] = oform.Clr_2_E1.Value
     
       rs![Clr 1 E2] = oform.Clr_1_E2.Value
       rs![Clr 2 E2] = oform.Clr_2_E2.Value
     
     
      For j = 2 To 29
         If (rs.Fields(j) = Null) Then
        DoCmd.GoToRecord , , acPrevious
         tampon = rs.Fields(j)
        DoCmd.GoToRecord , , acNext
        rs.Fields(j) = tampon
        End If
     
        Next
     
     
     
     
     
       rs.Update
       rs.Close
       Set rs = Nothing
    Merci pour votre aide.

  2. #2
    MC2
    MC2 est déconnecté
    Membre habitué

    Femme Profil pro
    Chef de projet en SSII
    Inscrit en
    Août 2002
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 55
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Chef de projet en SSII

    Informations forums :
    Inscription : Août 2002
    Messages : 148
    Points : 199
    Points
    199
    Par défaut
    Bonjour,
    je dirais plutôt qu'il faut dissocier tes 2 recordsets, l'un pour l'écriture, l'autre pour la lecture :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    Function MAJ_BaseAffaire(oform As Form)
     
     
    Dim db As DAO.Database
    Dim rs As DAO.Recordset 'écriture du nouvel enrgt
    Dim oControl As Control
    Dim i As String
    Dim j As Integer
    Dim rsLecture As DAO.Recordset 'lecture du dernier enrgt
     
    Dim tampon As Variant
     
     
     
           Set db = CurrentDb
           Set rs = db.OpenRecordset("Référence LOC", dbOpenDynaset) 'écriture
           'i = UCase(Forms![référence]![liste1])
           sSQL = "Select * From [Référence LOC] WHERE [LOC]= '" & oform.liste1 & "' order by [Date de Réference] DESC;"
           Set rsLecture = db.OpenRecordset(sSQL) 'lecture
          ' order by [Référence LOC].[Date de Réference] DESC
     
     
        rs.AddNew
     
        rs![Loc] = oform.liste1
     
        rs![Date de Réference] = oform.Texte108.Value
     
        rs![Axe long E1] = oform.Axe_long_E1.Value
        rs![Axe1 E1] = oform.Axe1_E1.Value
        rs![Axe2 E1] = oform.Axe2_E1.Value
        rs![ML long E1] = oform.ML_E1.Value
     
     
       rs![Axe long E2] = oform.Axe_long_E2.Value
       rs![Axe court E1] = oform.Axe1_E2.Value
       rs![Axe2 court E1] = oform.Axe2_E2.Value
       rs![ML E2] = oform.ML_E2.Value
     
       rs![Axe court E1] = oform.Axe_court_E1.Value
       rs![Axe1 court E1] = oform.Axe1_court_E1.Value
       rs![Axe2 court E1] = oform.Axe2_court_E1.Value
       rs![ML court E1] = oform.ML_court_E1.Value
     
       rs![Axe court E2] = oform.Axe_court_E2.Value
       rs![Axe1 court E2] = oform.Axe1_court_E2.Value
       rs![Axe2 court E2] = oform.Axe2_court_E2.Value
       rs![ML court E2] = oform.ML_court_E2.Value
     
       rs![Espace 90 E1] = oform.DDM_90_E1.Value
       rs![Espace 150 E1] = oform.DDM_150_E1.Value
       rs![Fsc1 E1] = oform.Fsc1_E1.Value
       rs![Fsc2 E1] = oform.Fsc2_E1.Value
     
       rs![Espace 90 E2] = oform.DDM_90_E2.Value
       rs![Espace 150 E2] = oform.DDM_150_E2.Value
       rs![Fsc1 E2] = oform.Fsc1_E2.Value
       rs![Fsc2 E2] = oform.Fsc2_E2.Value
     
       rs![Clr 1 E1] = oform.Clr_1_E1.Value
       rs![Clr 2 E1] = oform.Clr_2_E1.Value
     
       rs![Clr 1 E2] = oform.Clr_1_E2.Value
       rs![Clr 2 E2] = oform.Clr_2_E2.Value
     
     
      For j = 2 To 29
         If (rs.Fields(j) = Null) Then
              If rsLecture.eof = False then
                   'DoCmd.GoToRecord , , acPrevious 'inutile
                   tampon = rsLecture.Fields(j)
                   'DoCmd.GoToRecord , , acNext 'inutile
                   rs.Fields(j) = tampon
              End If
         End If
      Next
     
     
     
     
     
       rs.Update
       rs.Close
       Set rs = Nothing
       rsLecture.Close
       rsLecture = Nothing

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Récupération valeur d'une propriété type TStrings
    Par Stéphane Vaillant dans le forum Langage
    Réponses: 2
    Dernier message: 01/03/2003, 11h47
  2. [XMLRAD] récupération de donnée
    Par Mitch79 dans le forum XMLRAD
    Réponses: 7
    Dernier message: 30/01/2003, 15h36
  3. Réponses: 5
    Dernier message: 09/01/2003, 11h55
  4. récupération d'images
    Par MANU_2 dans le forum Composants VCL
    Réponses: 3
    Dernier message: 05/08/2002, 18h36
  5. Réponses: 4
    Dernier message: 05/06/2002, 12h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo