Bonjour à tous,
voila je cherche à faire passer des données d'une table à une autre avec une mshflexgrid. J'explique : j'ai deux tables (table_A et table_B), 2 mshflexgrid, et un bouton pr faire passer les données d'une ligne selectionnée de la table_A (4 champs dedans : A_id, A_nom,A_prenom,A_entreprise) à la table_B (B_id,B_nom,B_prenom,B_entreprise). Voici mon bout de code :
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
 
Option Explicit
 
Public cnx As ADODB.Connection
Public rst As ADODB.Recordset
Public rst2 As ADODB.Recordset
Public SQL As String
Public SQL2 As String
 
Private Sub Connexion()
 
Set cnx = New ADODB.Connection
Set rst = New ADODB.Recordset
Set rst2 = New ADODB.Recordset
 
cnx.Provider = "Microsoft.Jet.Oledb.4.0"
cnx.ConnectionString = App.Path & "\passe.mdb"
cnx.Open
 
End Sub
 
Private Sub Command1_Click()
 
rst.Find ("A_nom = " & MSHFlexGrid1)
While Not (rst2.EOF)
rst2.Fields = rst.Fields
rst2.MoveNext
Wend
rst2.Update
 
End Sub
 
Private Sub Form_Load()
 
Call Connexion
 
SQL = "SELECT * FROM Table_A"
rst.Open SQL, cnx, , adLockOptimistic
Set MSHFlexGrid1.DataSource = rst
 
SQL2 = "SELECT * FROM Table_B"
rst2.Open SQL2, cnx, , adLockOptimistic
Set MSHFlexGrid2.DataSource = rst2
 
End Sub
je n'arrive pas à trouver la propriété des mshflexgrid pr copier la ligne selectionnée dans l'autre base...
J'attends votre aide!
Merci