Results 1 to 3 of 3
  1. #1
    myaccesss is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    2

    Report saved in pdf is not refreshed

    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 :
    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
    When using the Kill command, sometimes I get an error 75. When using the Fso I always get an error 70.
    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 ?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'd use filesystemobject commands to check for the existence of the file first, if it's there delete it, then run your outputto command. It's likely the file will not be deleted or overwritten if access still thinks the file is open as well, even if you don't see it open in your task bar check your START > TASK MANAGER > PROCESSES you may notice instance of your .pdf viewer open and that may be a problem with not correctly closing your objects in your code.

  3. #3
    myaccesss is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    2
    As I always closed by DoCmd.Close acReport and I had no such problems with similar code for saving in xls format,
    I changed my default Microsoft PDF reader into the Adobe reader.
    Now the reports are showed in the reader as expected.
    So my conclusion is that Microsoft Pdf reader kept the report content somewhere and for along time in cache.
    I even do not need to delete an existing file with the same name (by kill or fso) as the existing file is overwriten by a new one
    without any warning.
    Thanks for helping me.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-05-2014, 02:24 PM
  2. Cannot locate my saved report
    By tstoneami in forum Reports
    Replies: 1
    Last Post: 08-01-2013, 09:38 AM
  3. Report design changes not saved
    By Julia Garrett in forum Reports
    Replies: 1
    Last Post: 10-29-2012, 10:03 AM
  4. Replies: 3
    Last Post: 09-14-2012, 04:10 PM
  5. Refreshing subform when form refreshed
    By Remster in forum Forms
    Replies: 27
    Last Post: 10-15-2010, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums