Recheche ligne contenant
c
bonjour
je cherche a exporter d'access les ligne suivant la valeur d'une cellule
cette valeur n'est pas complete donc je souhaite exporter toute les ligne comprenant cette valeur
exemple valeur de recherche A12
Donc dans access les lignes xA1215, a12s5, du moment que A12 existe soit pris en compte dans where reference
Sub actualise()
Application.ScreenUpdating = False
Année = Year(Date)
choixx = Sheets("Feuil2").Range("A2").Value
MsgBox choixx
'actualisation Base de donnée
Dim path_Bd As String
Dim cnn As New ADODB.Connection
Dim recSet As New ADODB.Recordset
Dim strDB, strSQL As String
Dim strTabla As String
Dim lngCampos As Long
Dim I As Long
Dim bBien As Boolean
On Error GoTo ControlError
bBien = True
'CONNECTION BASE DE DONNEE ACCESS ET OUVERTURE OUVERTURE
path_Bd = "G:\Modifproduits.mdb"
cnn.Provider = "Microsoft.ACE.OLEDB.12.0"
cnn.Properties("Data Source") = path_Bd
cnn.Properties("Jet OLEDB:Database Password") = ""
cnn.Open
strTabla = "Rapport"
strSQL = "SELECT N°,Client,Référence,N°FAI,Opérateur,Modif_Nomenclature,Modif_Coupe,Modif_Plan,Date_demande,Date_Traitement,Mail,Date_Tunisie ,N°_de_prod,Produit_Validé " _
& Chr(13) & "" & Chr(10) & "FROM .Rapport" _
& Chr(13) & "" & Chr(10) & "WHERE Référence = ' *choixx* '"
recSet.Open strSQL, cnn
'COPIER LES DONNEES SUR FEUILLE
Worksheets("Feuil1").Select
'effacement donnée sur EXCEL avant actualisation
limpiardatos = Sheets("Feuil1").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Feuil1").Range("A1:n" & limpiardatos).ClearContents
'copie bdd ACCESS
Sheets("Feuil1").Cells(2, 1).CopyFromRecordset recSet
lngCampos = recSet.Fields.Count
For I = 0 To lngCampos - 1
Sheets("Feuil1").Cells(1, I + 1).Value = recSet.Fields(I).Name
Next
'DECONNECTION
recSet.Close: Set recSet = Nothing
cnn.Close: Set cnn = Nothing
Sheets("Feuil1").Select
MsgBox "LA BASE DE DONNÉES ACTUALISÉE."
Application.ScreenUpdating = True
Salir:
On Error Resume Next
If Not bBien Then
MsgBox " BASE DE DONNÉE NON ACTUALISÉE, RETENTER PLUS TARD."
End If
recSet.Close: Set recSet = Nothing
cnn.Close: Set cnn = Nothing
Exit Sub
ControlError:
bBien = False
Resume Salir
End Submerci d'avance
Bonjour,
Si je comprends ta question ...
Ta macro se trouve dans un fichier Excel et tu veux importer ....pas exporter ... des données qui se trouvent dans une base Access ...
Si c'est bien cela ... à quel endtroit ta query s'arrrête de fonctionner ...???