My app is developed with Access.
I am trying to:
- generate a select query
- export the result in an Outlook mail (or at least in Excel)
- destroy the query at the end so there are no duplicates
My code:
Private Sub Commande24_Click()
Dim db As Database
Dim Qdf As QueryDef
Dim strSQL As String
Dim matr As Double
matr = DLookup("Matricule", "Employée", "Nom = '" & Me.Nom & "'")
strSQL = "SELECT Employée.Matricule, Employée.Département, Employée.Nom, Employée.Prénom, Employée.Grade, Employée.Silo, Entree.date_entree_g, Sortie.Date_sortie_e, Sortie.Type_s FROM (Employée INNER JOIN Entree ON Employée.N° = Entree.N_emp) INNER JOIN Sortie ON Employée.N° = Sortie.N_emp WHERE Employée.Matricule = '" & matr & "'"
Debug.Print sql