I have a query used as the source for a report. The query criteria is a List Box (List0). Trying to write code to loop through all of the entries of the List Box and save a separate report for each. Not getting errors -- but also getting a blank report! - Private Sub Command3_Click()
-
-
Dim i As Integer
-
Dim lbox As ListBox
-
Dim myPath As String
-
Dim strReportName As String
-
-
Set lbox = Me![List0]
-
myPath = "K:\CLE05\Business Resource Center\Opportunity Tracking\"
-
strReportName = lbox.ItemData(i)
-
-
For i = 0 To lbox.ListCount - 1
-
'Access each item with
-
'Me.ListBoxName.ItemData(i)
-
DoCmd.OutputTo acOutputReport, "Pipeline - All Rms - AUTO-REPORT", acFormatPDF, myPath & strReportName & ".pdf", False, , , acExportQualityPrint
-
-
'Debug.Print lbox.ItemData(i)
-
Next i
-
-
End Sub
I don't know why your report is blank but you will get the same result for every item in the list. Nothing changes as you go through your list. I think you want to move line 10 down between line 14 and 15.
Jim
6 1873
I don't know why your report is blank but you will get the same result for every item in the list. Nothing changes as you go through your list. I think you want to move line 10 down between line 14 and 15.
Jim
Got the answer from a different forum -- but here is the answer: -
Dim i As Integer
-
Dim lbox As ListBox
-
Dim myPath As String
-
Dim strReportName As String
-
Dim varItm As Variant
-
Dim str As String
-
-
str = ""
-
Set lbox = Me!List0
-
myPath = "C:\Users\ROSENBR\Documents\BRC\Report\"
-
-
If lbox.ItemsSelected.Count = 0 Then
-
MsgBox ("No items are currently selected.")
-
Exit Sub
-
End If
-
-
For Each varItm In lbox.ItemsSelected
-
strReportName = lbox.Column(0, varItm)
-
Debug.Print "chcking Loop logic with " & lbox.Column(0, varItm)
-
Debug.Print "2nd debug:" & strReportName
-
Debug.Print "[RM_FULL_NAME]= " & """" & lbox.Column(0, varItm) & """"
-
DoCmd.OpenReport "Pipeline - All Rms - AUTO-REPORT", acViewPreview, , "[RM_FULL_NAME]=" & """" & strReportName & """", acWindowNormal
-
DoCmd.OutputTo acOutputReport, "Pipeline - All Rms - AUTO-REPORT", acFormatPDF, myPath & strReportName & ".pdf", False, , , acExportQualityPrint
-
DoCmd.Close acReport, "Pipeline - All Rms - AUTO-REPORT", acSaveNo
-
Next varItm
NeoPa 32,556
Expert Mod 16PB
I'm very curious to know why you needed to go elsewhere when the correct answer was posted here two days ago?
NeoPa:
I'm very curious to know why you needed to go elsewhere when the correct answer was posted here two days ago?
Actually -- that wasn't the correct answer for the problem I was trying to solve.
NeoPa 32,556
Expert Mod 16PB
I'm happy to read your reasoning on this.
I read through the code and it seemed to me to be exactly what your code was suffering from. In the absence of your posting what happened when you tried it, I'm still of that opinion.
And I notice that the corrected code did in fact show the line moved into your loop as I suggested it needed to be. So what I pointed out was at least part of your problem. But I note that there was also the problem of the blank report which was mentioned but not really explained.
I'm glad you got your problem resolved.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: gregoryenelson |
last post by:
Hi all.
I have created a Report with a graph also on it.
The users, working through a form only (not the DB window) will want to view that Report run numbers of times against different criteria,...
|
by: cassey14 |
last post by:
Hi I hope someone help me on this..
I need to attach any files in my form like word,excel etc and save it on database..and also I need to open it at the same time..please help me... and also im...
|
by: jonosborne |
last post by:
Hi, i have managed to filter a report based on selections made in a list box but am totally confused with a message box that appears everytime i run my report.
Let me explain (i apologise for...
|
by: micarl |
last post by:
How would i print a report based on criteria selected from several
Combo Boxes as well as multiple Multi Select List Boxes, that are
located on the same form?
I can get one Multi List Box, just...
|
by: Neobeowulf |
last post by:
Team,
I'm totally stumped on this one. I'm trying to create a button called "Run Report" that opens a report based off a selection made in a combo box then filtered by a column in the report...
|
by: shawnrye1980 |
last post by:
I have a table that has 15 managers and I have queries that I need for there employees I have 5 union all queries because there are too many where clauses, I have done this and based off the main...
|
by: sroseindy |
last post by:
PLEASE HELP - I NEED THIS TO COMPLETE A CONTRACT!!!
Hi all,
I have a report based on a crosstab query. The number of columns is dynamic based on the selection criteria the user chooses. I’ve set up...
|
by: Seth Schrock |
last post by:
I may be trying the impossible. I'm trying to print multiple records on preprinted forms. However, each record may be on different forms. There will always be at least to different formats. So...
|
by: fredmart |
last post by:
Hi,
I'm having problems finding a way to apply conditional formatting based on comparing the text contents of two fields in two different tables.
What I'd like to do:
I've got two tables that...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |