INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Access Export with Formatting PDF Report using a list box

Access Export with Formatting PDF Report using a list box

(OP)
Access 2010
I am using a list box to export with formatting report to PDF but I would like to include the selected item from the list box into the final report path name. Is this possible?
Thank you for your review.


RE: Access Export with Formatting PDF Report using a list box

pattyjean,
Do you have any code or control names or anything else to share?

Duane
Hook'D on Access
MS Access MVP

RE: Access Export with Formatting PDF Report using a list box

(OP)

Yes this is the 1st form I created to go to the second form. I would like to put it all on one click.

Option Compare Database

Private Sub cmdPDF_Click()



On Error GoTo Err_Handler

Const MESSAGE_TEXT1 = "No current DATA."
Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
Dim strFullPath As String
Dim varFolder As Variant
strTest = Me.LstTerm.Value
MsgBox (strTest)

If Not IsNull(Me.LstTerm) Then
' build path to save PDF file
varFolder = DLookup("Folderpath", "pdfFolder")
strFullPath = varFolder & "\" & Me.cmdPDF_.Column(1) & "FALL-COHORT" & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "FALL-COHORT", acFormatPDF, strFullPath, True
End If
Else
MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
End If

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Here



End Sub

Private Sub LstTerm_Click()
DoCmd.OpenForm "startup2", , , , acViewPreview
End Sub

Private Sub LstTerm_DblClick(Cancel As Integer)

Dim strTest As String

DoCmd.OpenForm "startup2", , , , acViewPreview

strTest = "Click Open Report to pdf the Fall Cohort Retention by Term selected"
MsgBox (strTest)


End Sub

this is for the second form

Private Sub cmdPDF_Click()

On Error GoTo Err_Handler

Const MESSAGE_TEXT1 = "No current Year."
Dim strFullPath As String
Dim varFolder As Variant


If Not IsNull(Me.Term) Then
' build path to save PDF file
varFolder = DLookup("Folderpath", "pdfFolder")
If IsNull(varFolder) Then
MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
Else
strFullPath = varFolder & "\" & Me.Term & " " & "FALL-COHORT" & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "FALL-COHORT", acFormatPDF, strFullPath, True
End If
Else
MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
End If

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Here


End Sub

RE: Access Export with Formatting PDF Report using a list box

I'm still a bit confused about what you need and can't get past your error in code regarding "If End ... If". Consider using TGML to format your code after pasting it into a reply. It's much easier to read.

CODE --> vba

Private Sub cmdPDF_Click()
  On Error GoTo Err_Handler
  Const MESSAGE_TEXT1 = "No current DATA."
  Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
  Dim strFullPath As String
  Dim varFolder As Variant
  strTest = Me.LstTerm.Value
  MsgBox (strTest)
  If Not IsNull(Me.LstTerm) Then
    ' build path to save PDF file
    varFolder = DLookup("Folderpath", "pdfFolder")
    strFullPath = varFolder & "\" & Me.cmdPDF_.Column(1) & "FALL-COHORT" & ".pdf"
    ' ensure current record is saved before creating PDF file
    Me.Dirty = False
    DoCmd.OutputTo acOutputReport, "FALL-COHORT", acFormatPDF, strFullPath, True
  End If
   Else       'there is no If for this statement so it won't compile
    MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
  End If 
Exit_Here:
Exit Sub

Err_Handler:
  MsgBox Err.Description
  Resume Exit_Here
End Sub 

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close