brosenfelt
Registered User.
- Local time
- Today, 08:25
- Joined
- Aug 13, 2015
- Messages
- 36
So I will admit -- have NOT been working with Access for long (as well as VB)....but have a need, so ready to do whatever necessary to learn!
I have a sales report that I generate each week based on a query, which relies on the input from a combo box on a form. This works great - but I have select each salesperson, one at a time and run their reports separately.
I'd like to have some code that will run through each person on the list, generate their report, create the PDF, and email (or save) the file.
From my initial research, it appears I will need to utilize a List Box (vs a combo box), so I can select multiple salespersons for the report.
I've found a few examples of code to use...but a little lost on how to implement. I create a new form with a list box that queries the property table for the list. I then added a button to execute the code, and attempted to add this (with my control and reports names substituted). Getting all sorts of errors -- so not sure I'm on the correct path.
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003 with a Combo Box
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![ YourControl ]
'If Your Data Type is Numeric use this section
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport " YourReport ", acViewPreview, , _
"[ YourFieldControlSource ] = " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, " YourReport ", acFormatRTF, " DriveLetter :/ FolderName / FileName " & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, " YourReport "
Next
'If Your Data Type is a String use this section
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport " YourReport ", acViewPreview, , _
"[ YourFieldControlSource ] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, " YourReport ", acFormatRTF, " DriveLetter :/ FolderName / FileName " & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, " YourReport "
Next
Happy to my additional research on tutorials, but was hoping for some direction.
Thanks in advance.
Here is some relevant info from my database:
Query name: qry_pipeline_parse_allrm
Report name: Pipeline - All RMs
New form I created: frm_rmpick_listbox
List box control on that form: List0
Button control on that form: Command2
Thank you!:banghead:
I have a sales report that I generate each week based on a query, which relies on the input from a combo box on a form. This works great - but I have select each salesperson, one at a time and run their reports separately.
I'd like to have some code that will run through each person on the list, generate their report, create the PDF, and email (or save) the file.
From my initial research, it appears I will need to utilize a List Box (vs a combo box), so I can select multiple salespersons for the report.
I've found a few examples of code to use...but a little lost on how to implement. I create a new form with a list box that queries the property table for the list. I then added a button to execute the code, and attempted to add this (with my control and reports names substituted). Getting all sorts of errors -- so not sure I'm on the correct path.
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003 with a Combo Box
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![ YourControl ]
'If Your Data Type is Numeric use this section
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport " YourReport ", acViewPreview, , _
"[ YourFieldControlSource ] = " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, " YourReport ", acFormatRTF, " DriveLetter :/ FolderName / FileName " & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, " YourReport "
Next
'If Your Data Type is a String use this section
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport " YourReport ", acViewPreview, , _
"[ YourFieldControlSource ] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, " YourReport ", acFormatRTF, " DriveLetter :/ FolderName / FileName " & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, " YourReport "
Next
Happy to my additional research on tutorials, but was hoping for some direction.
Thanks in advance.
Here is some relevant info from my database:
Query name: qry_pipeline_parse_allrm
Report name: Pipeline - All RMs
New form I created: frm_rmpick_listbox
List box control on that form: List0
Button control on that form: Command2
Thank you!:banghead:
Last edited: