1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Dim rst As DAO.Recordset
Dim str As String
Dim rcd As DAO.Recordset
Dim qdf As QueryDef
Set rst = CurrentDb.OpenRecordset("select * from [Tbl_V]")
rst.MoveFirst
Do Until rst.EOF
str = "select * from Tbl_HUR where [SP]= '" & rst![v] & "'"
Set rcd = CurrentDb.OpenRecordset(str)
If rcd.RecordCount > 0 Then
Set qdf = CurrentDb.CreateQueryDef("TITRE - " & rst![v], str)
DoCmd.SendObject acSendQuery, qdf.Name, acFormatXLS, rst![recipient], , , qdf.Name, "TEXT", False
CurrentDb.QueryDefs.Delete qdf.Name
DoCmd.RunSQL "Delete from tbl_X where [sp] = '" & rst![v] & "'"
Set qdf = Nothing
End If
rst.MoveNext
Set rcd = Nothing
Loop
Set rst = Nothing |
Partager