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 1875
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |