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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
Private Sub Form_Load()
Dim SQL As String
Set cn = New ADODB.Connection
'Création des recordset
Set rsFourn = New ADODB.Recordset
Set rsCat = New ADODB.Recordset
Set rsSousCat1 = New ADODB.Recordset
Set rsSousCat2 = New ADODB.Recordset
Set rsSousCat3 = New ADODB.Recordset
'Création des lien
Set BndFourn = New BindingCollection
Set BndCat = New BindingCollection
Set BndSousCat1 = New BindingCollection
Set BndSousCat2 = New BindingCollection
Set BndSousCat3 = New BindingCollection
'ouverture de la BD
cn.Provider = "MSDataShape"
cn.Open "Data Provider = Microsoft.Jet.OLEDB.3.51;" & " Data Source = C:\TFE\Stock2.mdb"
SQL = " SHAPE {SELECT * FROM `CATEGORIE`} AS Command1 APPEND (( SHAPE {SELECT * FROM `SOUSCATEGORIE1`} AS Command2 APPEND (( SHAPE {SELECT * FROM `SOUSCATEGORIE2`} AS Command3 APPEND (( SHAPE {SELECT * FROM `SOUSCATEGORIE3`} AS Command4 APPEND ({SELECT * FROM `FOURNITURE`} AS Command5 RELATE 'ID_SousCategorie3' TO 'ID_SousCategorie3') AS Command5) AS Command4 RELATE 'ID_SousCategorie2' TO 'ID_SousCategorie2') AS Command4) AS Command3 RELATE 'ID_SousCategorie1' TO 'ID_SousCategorie1') AS Command3) AS Command2 RELATE 'ID_Categorie' TO 'ID_Categorie') AS Command2"
'Ouverture des recorsets
rsFourn.Open SQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
rsCat.Open SQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
rsSousCat1.Open SQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
rsSousCat2.Open SQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
rsSousCat3.Open SQL, cn, adOpenDynamic, adLockOptimistic, adCmdText
'Se placer sur le 1er
rsFourn.MoveFirst
rsCat.MoveFirst
rsSousCat1.MoveFirst
rsSousCat2.MoveFirst
rsSousCat3.MoveFirst
'Liaison du recordset à la source de donnée des liens
Set BndFourn.DataSource = rsFourn
Set BndCat.DataSource = rsCat
Set BndSousCat1.DataSource = rsSousCat1
Set BndSousCat2.DataSource = rsSousCat2
Set BndSousCat3.DataSource = rsSousCat3
'Test de recordset vide
With rsFourn
If .RecordCount = 0 Then
StatusBar1.Panels.Item(1).Text = "Aucun compte n'a été créé"
StatusBar1.Panels.Item(2).Text = "Prêt..."
Exit Sub
End If
End With
With rsCat
If .RecordCount = 0 Then
StatusBar1.Panels.Item(1).Text = "Aucun compte n'a été créé"
StatusBar1.Panels.Item(2).Text = "Prêt..."
Exit Sub
End If
End With
With rsSousCat1
If .RecordCount = 0 Then
StatusBar1.Panels.Item(1).Text = "Aucun compte n'a été créé"
StatusBar1.Panels.Item(2).Text = "Prêt..."
Exit Sub
End If
End With
With rsSousCat2
If .RecordCount = 0 Then
StatusBar1.Panels.Item(1).Text = "Aucun compte n'a été créé"
StatusBar1.Panels.Item(2).Text = "Prêt..."
Exit Sub
End If
End With
With rsSousCat3
If .RecordCount = 0 Then
StatusBar1.Panels.Item(1).Text = "Aucun compte n'a été créé"
StatusBar1.Panels.Item(2).Text = "Prêt..."
Exit Sub
End If
End With
'Affectation des recordsets aux textbox
With BndFourn
.Add Text1(0), "Text", "Denomination", , "Dénomination"
'.Add Text1(5), "Text", "Quantite", , "Quantitée"
'.Add Text1(6), "Text", "Prix", , "Prix"
'.Add Text1(7), "Text", "Professionel", , "Professionel"
'.Add Text1(8), "Text", "Remarque_Fourniture", , "Remarque"
End With
BndCat.Add Text1(1), "Text", "Int_Categorie", , "Catégorie"
BndSousCat1.Add Text1(2), "Text", "Int_SousCategorie1", , "Sous-Catégorie1"
BndSousCat2.Add Text1(3), "Text", "Int_SousCategorie2", , "Sous_Categorie2"
BndSousCat3.Add Text1(4), "Text", "Int_SousCategorie3", , "Sous-Catégorie3"
'Set DataGrid1.DataSource = rsFourn!ID_SousCategorie3.Value
'Call MAJ_BarreEtat
End Sub |