473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to post certain reports into a list box?

I want to have a list box that show certain reports, anybody can help?
when I do my querry, it shows all the available reports, not certain reports that I want.
Thanks alot!
Jan 18 '07 #1
7 1596
nico5038
3,080 Expert 2GB
In a case like this I normally "code" my report names like:
rptAutoOrders
rptAutoInvoices, etc.
Thus I can filter for "Like rptAuto*"

Idea ?

Nic;o)
Jan 20 '07 #2
ADezii
8,834 Expert 8TB
I want to have a list box that show certain reports, anybody can help?
when I do my querry, it shows all the available reports, not certain reports that I want.
Thanks alot!
Here is sample code (Access 2003) that will load only Reports beginning with rpt into a List Box called lstTest. Hope this helps.
Expand|Select|Wrap|Line Numbers
  1. Dim MyReport As Report, numOfReports As Integer, T As Integer
  2.  
  3. Me![lstTest].RowSourceType = "Value List"
  4.  
  5. numOfReports = CurrentProject.AllReports.Count
  6.  
  7. For T = 0 To numOfReports - 1
  8.   If Left$(CurrentProject.AllReports(T).Name, 3) = "rpt" Then
  9.     lstTest.AddItem CurrentProject.AllReports(T).Name
  10.   End If
  11. Next
Jan 20 '07 #3
NeoPa
32,556 Expert Mod 16PB
ADezii,
There is another way to access items in a collection (Your way works fine, but this (For...Each) is an alternative which takes a little less setting up).
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_OnOpen()
  2.     Dim strRowSource As String
  3.     Dim rptThis As Report
  4.  
  5.     For Each rptThis in CurrentProject.AllReports
  6.         If Left(rptThis.Name, 3) = "rpt" Then _
  7.             strRowSource = strRowSource & ";" & rptThis.Name
  8.     Next
  9.     With Me!lstTest
  10.         .RowSourceType = "Value List"
  11.         .RowSource = Mid(strRowSource, 2)
  12.     End With
  13. End Sub
Jan 21 '07 #4
ADezii
8,834 Expert 8TB
ADezii,
There is another way to access items in a collection (Your way works fine, but this (For...Each) is an alternative which takes a little less setting up).
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_OnOpen()
  2.     Dim strRowSource As String
  3.     Dim rptThis As Report
  4.  
  5.     For Each rptThis in CurrentProject.AllReports
  6.         If Left(rptThis.Name, 3) = "rpt" Then _
  7.             strRowSource = strRowSource & ";" & rptThis.Name
  8.     Next
  9.     With Me!lstTest
  10.         .RowSourceType = "Value List"
  11.         .RowSource = Mid(strRowSource, 2)
  12.     End With
  13. End Sub
NeoPa:
Correct me if I'm wrong, but I'm pretty sure that your approach will fail. The AllReports Collection does not contain Report Objects but AccessObject Objects. rptThis should not be declared as Report but as an Object as in:
Expand|Select|Wrap|Line Numbers
  1. Dim strRowSource As String
  2. Dim rptThis As Object
  3.  
  4.     For Each rptThis In CurrentProject.AllReports
  5.         If Left(rptThis.Name, 3) = "rpt" Then _
  6.             strRowSource = strRowSource & ";" & rptThis.Name
  7.     Next
  8.  
  9.     With Me!lstTest
  10.         .RowSourceType = "Value List"
  11.         .RowSource = Mid(strRowSource, 2)
  12.     End With
Jan 22 '07 #5
NeoPa
32,556 Expert Mod 16PB
You're absolutely right ADezii (and even if not - you would have been right to raise it for discussion).
I was working from your code and assumed (incorrectly it seems) that an M$ Office collection called AllReports, would contain Reports (How dumb am I?).
I only used this in earnest today (after my post here) when I was trying to delete all reports from a database and it refused to let me Dim the variable as a Report !?! So I used Object there (as you suggest). It didn't let me delete them anyway using DoCmd.Delete so it was a waste of time :( I always try to be specific with my Dims as clarity always helps with understanding I find. In this case though, apparently it is only defined as an Object.
Anyway, thanks for finding & fixing :)
Jan 22 '07 #6
Thanks alot guys!
Jan 29 '07 #7
NeoPa
32,556 Expert Mod 16PB
No problem Elaine - We're glad to help.
Jan 29 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Håkan Persson | last post by:
Hi. I am trying to set up a simple HTTP-server but I have problems reading data that is beeing POSTed. class httpServer(BaseHTTPServer.BaseHTTPRequestHandler): def do_POST(self): input =...
1
by: Ruth | last post by:
Alison, You are going to find this a real coincidence! To begin with, I am Roberta Laird's husband. I think you know Roberta. We also are friends with Laura McConnell. Anyway, I am in business...
7
by: Sink | last post by:
Hi, Looking at reporting tools and was wondering if anyone else has gone thru this. Crystal seems rediculously expensive once you take into account licensing, while Active is runtime-free meaning...
2
by: B.Newman | last post by:
I've got some VB.NET code that *should* get a list of reports from an Access MDB and populate a list box with them. It doesn't detect any of the reports at all. oAccess.Reports.Count comes up as...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
1
by: alphaomega3 | last post by:
I have created a form for listing my reports using tips and code from Allen Browne's website. The Code is as Follows: Function EnumReports(fld As Control, id As Variant, row As Variant, col As...
0
by: Michael Hudson | last post by:
The PyPy team is sprinting at EuroPython again and we invite you to participate in our 3 day long sprint at the conference hotel - Reval Hotel Lietuva. If you plan to attend the sprint we...
13
by: clarencelai | last post by:
I am constantly creating reports for a group of users. To simply the user interface, I would like to create a form that will list the reports in a drop down list (combo box). The user would...
0
by: akshaycjoshi | last post by:
Most of you people are already familier with the working of crystal reports unlike me.I am working on an application when I have no other option but to use CR. It is very diff. for me to read an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.