Bonjour ,débutante en vba access ,je sollicite votre aide.

J'ai une fonction qui exporte une commande en csv.Je voudrais que chaque fois qu'une nouvelle commande est générée ,il supprime le fichier temporaire précédent .J'ai utilisé la fonction "kill" .Mais à chaque nouvelle commande ,il met les enregistrements à la suite de la commande précédente .
Voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Public Function exportcommandeSob()
Dim temp As String
Dim rs As Recordset
 
On Error GoTo err_exportcommandeSob:
 
temp = getCommandesDir & "temp" & ".csv"
 
If Dir(temp) = "" Then Kill temp
 
intFic = FreeFile
 
Open temp For Output As intFic
    Set rs = CurrentDb.OpenRecordset("Select * from commande where ComID <> 0" & ComID & ";")
    With rs
        Print #intFic, rs!ComCode & ";" & rs!ComRef & ";" & rs!Email & ";" & rs!Commentaire
    End With
    Set rs = CurrentDb.OpenRecordset("Select * from commandedetail WHERE  ComID <> 0" & ComID & ";")
    With rs
        Do Until .EOF
        Print #intFic, rs!MedicRef & ";" & rs!QuantiteCondPrim
        rs.MoveNext
        Loop
 
    End With
Close intFic
Set rs = Nothing
C'est la version access Xp
Merci de votre réponse et aide