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
|
Public cnn As New ADODB.Connection
Public rst As New ADODB.Recordset
Public rst1 As New ADODB.Recordset
Public rst2 As New ADODB.Recordset
Private Sub Command1_Click()
Dim varbookmark As Variant
' je fait une recherche sur tout le fichier excel
For k = 3 To 1000
rst.MoveFirst
'Extraction de la donnée a partir du fichier excel
Text1 = Extraire(chmbdd, k + 1, 3)
larecherche = Text1.Text
varbookmarks = rst.Bookmark
' recherche dans la base de données dans la ( tb_c )
rst.Find "Num_C='" & larecherche & "'"
If rst.EOF Or rst.BOF Then
rst.Bookmark = varbookmarks
MsgBox "Désolé," & vbCrLf & " non trouvé"
Else
' recherche validé , affichage sur mon text3 de idc
Set Text3.DataSource = rst
Text3.DataField = "idc"
' recherche du (idc) dans la table (tb_c_to_r) pour trouver le (idr)
larecherche = Text3.Text
varbookmarks = rst1.Bookmark
rst1.Find "idC='" & larecherche & "'"
If rst1.EOF Or rst1.BOF Then
rst1.Bookmark = varbookmarks
MsgBox "Désolé," & vbCrLf & "non trouvé"
Else
'affichage des données trouvée (idc et idr )
Set Text2.DataSource = rst1
Set Text6.DataSource = rst1
Text2.DataField = "idC"
Text6.DataField = "idR"
larecherche = Text6.Text
varbookmarks = rst2.Bookmark
' recherche de idr dans la ( tb_r ) pour trouver la correspondance ( type_r)
rst2.Find "idRis='" & larecherche & "'"
If rst2.EOF Or rst2.BOF Then
rst.Bookmark = varbookmarks
MsgBox "Désolé," & vbCrLf & "non trouvé"
Else
For m = 0 To 1
Set Text5(m).DataSource = rst2
Next m
Text5(0).DataField = "idr"
Text5(1).DataField = "type_r"
End If
End If
End If
Next k
End Sub
lblbbd = App.Path & "\essai.mdb"
cnn.Provider = "Microsoft.Jet.OLEDB.3.51"
cnn.ConnectionString = App.Path & "\essai.mdb"
cnn.Open
If cnn.State = adStateOpen Then
lblbbd = App.Path & "\essai.mdb"
MsgBox "Connexion reussi", vbInformation, "Connexion a la base de données"
rst.Open "SELECT * FROM tb_CAS;", cnn, adOpenKeyset, adLockBatchOptimistic
rst1.Open "SELECT * FROM tb_CAS_to_Ris;", cnn, adOpenKeyset, adLockBatchOptimistic
rst2.Open "SELECT * FROM tb_Risque;", cnn, adOpenKeyset, adLockBatchOptimistic
End If
'If rst.RecordCount = 0 Then
' MsgBox "Il n'y a aucun enregsitrement dans la base de données"
' End
' End If
' allocation du recordset au datagrid pour affichage
Set dg.DataSource = rst
dg.Refresh
End Sub |
Partager