Results 1 to 4 of 4
  1. #1
    sorenwrang is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    3

    Exclamation Detail_Print is sometimes not executed.

    Hi all,

    I am experiencing a baffling problem when opening a report in Print Preview; the code in Detail_Print is sometimes not executed.



    First of all, let's make sure that I actually understand how it should work. As far as I understand, when opening the report in Print Preview, Detail_Format followed by Detail_Print is executed once for each data entry.

    Now, some details about the problem I experience. The code I have put in Detail_Print is a routine taking care of generating the Table of Content for my report. When opening the report, the Table of Content is either complete or not there at all. This indicates that the Detail_Print is either executed as it should, for each entry or not executed at all. The frequency of the problem is random. Sometimes the Table of Content is generated succesfully several times in a row when opening the report. Other times, I can open the report 2-3-4-5 times in a row where the Table of Content is missing.

    By single-stepping through the code, I have discovered that the problem is not my code inside Detail_Print. When executing "End Sub" in the end of Detail_Format, it should continue to Detail_Print. Instead, Detail_Format for the next entry is executed. So, the problem is that it does not enter Detail_Print at all. This will obviously result in a missing Table of Content, as the code is never executed.

    Can anyone tell me what is going on here?

    Best regards,
    Søren

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    yes, it should run for every record, BUT you didn't show the code of what youre doing , which could be a factor.
    pls post code.

  3. #3
    sorenwrang is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    3
    Code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
          If cmb_Type = 4 Then 'If the entry is of type 4, it is a header and should therefore be listed in the table of content
             If CharCount(Me.tb_SectionNumber, ".") < 4 Then
                rsTOC.FindFirst "ID=" & Me.tb_ID 'rsTOC is a table recordset. So, when adding entries to rsTOC, it is added to a table. All entries have the unique field ID
                If rsTOC.NoMatch Then 'If, for some reason, the entry is already in the ToC, skip it.
                   m_TOCUpdated = True
                      rsTOC.AddNew
                         'Adding the entry to the ToC table (rsTOC)
                         rsTOC!ID = Me.tb_ID
                         rsTOC![SectionNumber] = Me.tb_SectionNumber
                         rsTOC![Text] = Me.tb_Text
                         rsTOC![Page] = Page
                      rsTOC.Update
                         
                Else
                   If rsTOC!Page <> Page Then
                      m_TOCUpdated = True
                      rsTOC.Edit
                         rsTOC![Page] = Page
                      rsTOC.Update
                   End If
                End If
             End If
         End If
    End Sub
    This is the code inside Detail_Print. However, I doubt this is relevant, as, when the issue occurs, it never enters the Detail_Print at all.
    The randomness of the problem is what annoys me the most. Using exactly the same content, Detail_Print is sometimes executed, sometimes not. As I stated in my original post; it is either executed for all entries (leading to a successful generation of the table of content) or for no entries at all (leading to a missing table of content).

  4. #4
    sorenwrang is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2016
    Posts
    3
    Hasn't anyone experienced similar problems?

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

Similar Threads

  1. Call function is not executed
    By fluffyvampirekitten in forum Access
    Replies: 12
    Last Post: 11-04-2015, 10:11 AM
  2. RIGHT most line VBA for Detail_Print
    By hollyanneu2 in forum Programming
    Replies: 2
    Last Post: 04-28-2015, 03:34 PM
  3. Detail_Print
    By CamtheChamp in forum Reports
    Replies: 3
    Last Post: 07-16-2012, 03:40 PM
  4. Replies: 1
    Last Post: 07-16-2012, 03:10 PM

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