Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CreateTargetPDF_Click()
- Dim strWhere As String
- Dim ctl As Control
- Dim varItem As Variant
- Dim ReportName As String
- Dim counter As Byte
- StartingFolder = BrowseForFolder("\Documents")
- 'confirm selection
- If Me.EmployeeNameList.ItemsSelected.Count = 0 Then
- MsgBox "Must select at least 1 Employee"
- Exit Sub
- End If
- 'add selected values to string
- Set ctl = Me.EmployeeNameList
- For Each varItem In ctl.ItemsSelected
- strWhere = strWhere & "'" & ctl.ItemData(varItem) & "'" & ","
- 'trim trailing comma and '
- strWhere = Left(strWhere, Len(strWhere) - 1)
- ReportName = Replace(strWhere, "'", "")
- 'Select report based on Comp Title
- Role = CompTitleList.Value
- ReportFormat = "Rpt_Target" & Role
- 'open report
- DoCmd.OpenReport ReportFormat, acViewPreview, , "[Emp_FullName] IN(" & strWhere & ")"
- 'print report
- DoCmd.OutputTo acOutputReport, ReportFormat, acFormatPDF, StartingFolder & "/" & ReportName & " - 2017 " & Role & " Target Statement" & ".pdf", False
- 'Close Report
- DoCmd.Close acReport, ReportFormat
- Next varItem
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement