From within a Form I launch a report.
In the report there is a button for saving it in pdf format (like c:\Documents\PhotoInventory-20160222.pdf)
When launching the report a second time with a different SQL Where clause, it's properly showed on screen with his new content.
When clicking again the save button ...-20160222.pdf (should be) killed and a new file with the same name (should be) created.
However, it's content is that from the 1st run. It continues this behavior on and on.
What's also weird : there is a timestamp in the report. The timestamp is earlier than the timestamp in the file's properties.
And this timestamp does not change (even hours later).
This is the sourcecode(without error handling) concerned :
When using the Kill command, sometimes I get an error 75. When using the Fso I always get an error 70.Public Function BuildFileName(MyName As String, MyExtension As String) As String
Dim strPath As String
Dim strFile As String
Dim strDate As String
strDate = format(Now(), "yyyymmdd")
strPath = DocumentPath()
strFile = strPath & "" & MyName & strDate & "." & MyExtension
If Dir(strFile) <> "" Then
SetAttr strFile, vbNormal
Pause (1)
'Kill strFile
'Dim fso
'Set fso = CreateObject("Scripting.FileSystemObject")
'fso.DeleteFile (strFile)
End If
BuildFileName = strFile
End Function
Private Sub btnPdf_Click()
Dim strFile As String
strFile = BuildFileName("PhotoInventory-", "pdf")
DoCmd.OutputTo acOutputReport, Me.Report.Name, acFormatPDF, strFile, True
DoCmd.Close acReport, "PhotoInventory"
End Sub
So in the meantime I delete the saved pdf between 2 runs by hand.
It seems that the first report is buffered somewhere in memory and is all the time created again.
The drive is virus free.
Any suggestions for debugging ?