Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Report to pdf, if on openform and subform.visible

    I have a report with a checkbox

    if checkbox = true then
    me.frmsub.visible = true
    end if

    the subform property for visibility is false



    this works fine when viewing the report

    however when I email as pdf the subform does not show - I thought that the open event would run the vba before it makes it a pdf?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I have report/subreport arrangements that go to PDF just fine.

    Try code in the Format event of whichever section the subreport is in. However, Format event runs only in PrintPreview or direct to printer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    I have report/subreport arrangements that go to PDF just fine.

    Try code in the Format event of whichever section the subreport is in. However, Format event runs only in PrintPreview or direct to printer.
    I have a button that sends the report without it having opened yet as a pdf - I get all the right information on the report as well as the subform if I make visible true however I have visible on false to begin with as sometimes depending on the if condition I can't have the subform show. I see a report has two view options when opening (property), one is report and the other is preview - could this have an affect?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Yes, reports act differently between Report and PrintPreview views (Normal view is straight to printer is same as PrintPreview).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Have to bring this one up again.

    sendobject PDF format doesn't apply the load() code before making the PDF in the email. Would it something where I would have to load the report first then run the send object?

    I'd like to hide the subreport if field checkbox "joiningschool" is false and it doesn't hide in the pdf. I have tried changing the form to load print preview and report view in the properties with no difference (pdf defaults to print preview I guess anyway).

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I just tested code that conditionally displays a subreport in main report Detail section. Code is in Format event of Detail section. Open report in PrintPreview. Run SendObject code. The PDF displays subreport appropriately according to the condition. Can't replicate your issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    I just tested code that conditionally displays a subreport in main report Detail section. Code is in Format event of Detail section. Open report in PrintPreview. Run SendObject code. The PDF displays subreport appropriately according to the condition. Can't replicate your issue.
    I ran code that opens the report first ac achidden, the pdf then appears to display subreport appropriately. If I don't open the report first it doesn't. I would like just send the report not have to open it.

    I also noticed that because I had opened one report with one record and hidden it without closing it if I followed suit with another report it would make a pdf of the previous record not the current...

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    i.e. in order for the pdf to have the subform hide/show you would have to run the report first.

    Ideally I guess you would have to open, send object and then close the report? - I haven't had luck in getting this to work

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Now tested report opened in Preview but Hidden. PDF still good.

    Post all relevant code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Now tested report opened in Preview but Hidden. PDF still good.

    Post all relevant code.
    I imagine that would work - it works for me. But that is opening the report first right? What about not opening the report at all. The idea is that the user is on a form, clicks a button and sends the report without viewing the report.

  11. #11
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Entire proceedure minus the emailmsgconfirm
    Code:
    Private Sub btnEmailConfirmation_Click()
    
    
    Me.Refresh
    
    
    On Error GoTo ErrorHandler
    
    
    AlternativeName = IIf(Me.SchoolTypeID = 3, " or the Director, ", IIf(Me.SchoolTypeID = 9, " ", " or the Principal,"))
    
    
    TourOrganiserORPeter = IIf(Me.MergedNameT = Null, "ANAME" & vbCrLf & "Manager", Me.MergedNameT & vbCrLf & vbCrLf & "Tour Organiser")
    
    
    emailmsgconfirm = "###"
    
    
    
    
    If IsNull(Me.TeacherEmail) Or IsNull(Me.SchoolEmail) Then
    MsgBox "You require an email in the Teacher & School Email field first"
    Else
    
    
    DoCmd.SendObject acSendReport, "rptBookingEmail", "PDFFormat(*.pdf)", TeacherEmail, SchoolEmail, "", "ANAME - Booking Confirmation", emailmsgconfirm, True
    
    
    End If
    
    
    If Me.ConfirmationSent1st = True Then
    Else
    End If
    If Me.ConfirmationSent1st = False Then
    Me.ConfirmationSent1st = True
    End If
    
    
    ErrorHandler:
    Select Case Err
    Case 2501
    MsgBox "You have cancelled the email"
    
    
    End Select
    Me.Refresh
    End Sub

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Again, PDF is good even though report was not opened but sent directly to printer. The Format event triggers.

    Can't see anything wrong with that procedure.

    Where is the conditional code for displaying subreport?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Again, PDF is good even though report was not opened but sent directly to printer. The Format event triggers.

    Can't see anything wrong with that procedure.

    Where is the conditional code for displaying subreport?
    on the load event of the report (that is not opened, just sent as pdf)

    Code:
    If Me.JoiningSchool = -1 Then
    Me.rptNewBookingEmailSub.Visible = True
    End If

  14. #14
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I am emailing​ the pdf using sendobject - not printing it...

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Same here. SendObject is generating a PDF and attaching it to email message. I send message. Go open email which has attachment. Open attached PDF and it is properly formatted.

    That code also looks good. Use Format event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Image visible if listed in a subform
    By nigelbloomy in forum Forms
    Replies: 4
    Last Post: 12-20-2012, 04:40 PM
  2. Macro for visible field in subform
    By g=2012 in forum Access
    Replies: 7
    Last Post: 09-11-2012, 02:23 PM
  3. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  4. Replies: 2
    Last Post: 12-17-2010, 11:12 PM
  5. OpenForm in subform not working
    By eyuen in forum Forms
    Replies: 3
    Last Post: 11-10-2010, 12:03 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