Export formulaire filtré access vers excel

dj dim

XLDnaute Occasionnel
Bonjour à tous et toutes,

Je suis en grosse galère avec mon code après de multiples recherches et tentatives ... Je désespère ! :confused:

J'ai un formulaire de recherche multicritères avec macro qui fonctionne (jusque ici) ! ;)

Le soucis c'est que je souhaite exporter le résultat obtenu sous excel et là ça coince.

Voici le code :
Code:
' 

FONCTION DE RECHERCHE
' ---
Function Recherche()
Dim strFiltre As String


' Construction du filtre
On Error GoTo RechercheErreur
strFiltre = ""

If Not IsNull(Me![critere_Départ Pays]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Départ Pays] LIKE " & "'*" & Replace(Me![critere_Départ Pays], "'", "''") & "*'" & ")"
End If
If Not IsNull(Me![critere_Départ Département]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Départ Département] LIKE " & "'*" & Replace(Me![critere_Départ Département], "'", "''") & "*'" & ")"
End If
If Not IsNull(Me![critere_Départ Ville]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Départ Ville] LIKE " & "'*" & Replace(Me![critere_Départ Ville], "'", "''") & "*'" & ")"
End If
If Not IsNull(Me![critere_Arrivée Pays]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Arrivée Pays] LIKE " & "'*" & Replace(Me![critere_Arrivée Pays], "'", "''") & "*'" & ")"
End If
If Not IsNull(Me![critere_Arrivée Département]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Arrivée Département] LIKE " & "'*" & Replace(Me![critere_Arrivée Département], "'", "''") & "*'" & ")"
End If
If Not IsNull(Me![critere_Arrivée Ville]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Arrivée Ville] LIKE " & "'*" & Replace(Me![critere_Arrivée Ville], "'", "''") & "*'" & ")"
End If

If Not IsNull(Me![critere_Affrété]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Affrété Nom] LIKE " & "'*" & Replace(Me![critere_Affrété], "'", "''") & "*'" & ")"
End If

If Not IsNull(Me![critere_Client Nom]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Client Nom] LIKE " & "'*" & Replace(Me![critere_Client Nom], "'", "''") & "*'" & ")"
End If

If Not IsNull(Me![critere_Agence]) Then
    If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    strFiltre = strFiltre & "([Société] LIKE " & "'*" & Replace(Me![critere_Agence], "'", "''") & "*'" & ")"
End If




'If Not IsNull(Me![critere_Agence]) Then
    'If strFiltre <> "" Then strFiltre = strFiltre & " AND "
    'strFiltre = strFiltre & "([Société] LIKE " & "'*" & Replace(Me![critere_Agence], "'", "''") & "*'" & ")"
'End If





' Application du filtre
With Me.sfmResultats.Form
    .Filter = strFiltre
    .FilterOn = True
End With
Exit Function

RechercheErreur:
    MsgBox "Erreur :" & Err.Description, vbExclamation, "Recherche"
    Exit Function
End Function
 

Statistiques des forums

Discussions
312 844
Messages
2 092 760
Membres
105 529
dernier inscrit
StarExcel