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
| Sub RequeteClasseurFerme()
Dim Cn As ADODB.Connection
Dim Fichier As String
Dim NomFeuille As String, texte_SQL As String, Prod As String
Dim Rst As ADODB.Recordset
Fichier = "T:\TEMP\CC\Classeur1.xls"
NomFeuille = "Feuil1"
Prod = "BR35075334"
Set Cn = New ADODB.Connection
'--- Connection ---
With Cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & Fichier & _
";Extended Properties=Excel 8.0;"
.Open
End With
texte_SQL = "SELECT NSCLIENT FROM [" & NomFeuille & "$] where NSCLIENT =[" & Prod & "$]"
Set Rst = CurrentDb.Recordset(texte_SQL)
If Rst.RecordCount > 0 Then
MsgBox ("cette valeur existe")
Else
MsgBox ("elle n'existe pas")
End If
Cn.Close
Set Cn = Nothing
End Sub |
Partager