473,387 Members | 1,493 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,387 software developers and data experts.

VB.NET - reading reports from Access MDB

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 0. There are four reports in the MDB. They are not hidden.
They don't have special characters in their names. There is no security
on the MDB and no one else is accessing it.

I have code currently to only show reports that start with "rpt_", but
I've taken that out and it doesn't help. Also, the .Count occurs before
that.

It does open the MDB just fine. If I uncomment the line to run a
specific report by name, that report runs fine as well, so I know it
can find the reports. It just can't find the .Reports collection.

Here's the code:

' Start a new instance of Access for Automation
Dim oAccess as Access.Application
Dim sDBPath as String
Dim nCount as Integer

oAccess = New Access.ApplicationClass
' Determine the path
sDBPath = gAppEnv.CvsDataPath
' open the database
oAccess.OpenCurrentDatabase(sDBPath, False)
' read in all of the available reports
nCount = oAccess.Reports.Count
For Each oRpt In oAccess.Reports
cRptName = oRpt.Name
' if it starts with "rpt_"
If cRptName.Substring(0, 4).ToLower = "rpt_" Then
lstReports.Items.Add(cRptName.Split("rpt_")(1))
End If
Next
' just run a report by name
'oAccess.Visible = True
'oAccess.DoCmd.OpenReport("rpt_Validation Error Report",
Access.AcView.acViewPreview)

Nov 21 '05 #1
2 3241
Hi B,

The Reports collection holds only the open reports

try
nCount = oAccess.Containers("Reports").Documents.Count
For Each oRpt In oAccess.Containers("Reports").Documents

Doug

"B.Newman" <b2******@or.blm.gov> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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 0. There are four reports in the MDB. They are not hidden.
They don't have special characters in their names. There is no security
on the MDB and no one else is accessing it.

I have code currently to only show reports that start with "rpt_", but
I've taken that out and it doesn't help. Also, the .Count occurs before
that.

It does open the MDB just fine. If I uncomment the line to run a
specific report by name, that report runs fine as well, so I know it
can find the reports. It just can't find the .Reports collection.

Here's the code:

' Start a new instance of Access for Automation
Dim oAccess as Access.Application
Dim sDBPath as String
Dim nCount as Integer

oAccess = New Access.ApplicationClass
' Determine the path
sDBPath = gAppEnv.CvsDataPath
' open the database
oAccess.OpenCurrentDatabase(sDBPath, False)
' read in all of the available reports
nCount = oAccess.Reports.Count
For Each oRpt In oAccess.Reports
cRptName = oRpt.Name
' if it starts with "rpt_"
If cRptName.Substring(0, 4).ToLower = "rpt_" Then
lstReports.Items.Add(cRptName.Split("rpt_")(1))
End If
Next
' just run a report by name
'oAccess.Visible = True
'oAccess.DoCmd.OpenReport("rpt_Validation Error Report",
Access.AcView.acViewPreview)

Nov 21 '05 #2
Thanks, Doug, but my Access object doesn't recognize any property
called Containers. I've read that some drivers should be downloaded
from Microsoft and installed to allow better VB.Net Office automation,
but I can't install anything on my box and my users won't be able to
either. Is that the problem or can I make it work with the existing
Microsoft Access 10.0 Object Library?

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
2
by: Andrew | last post by:
Hi there: I can successfully control a report's GroupLevel ControlSource property by using: ..Reports!rptEESTMT_A.GroupLevel(i).ControlSource = "CorpName" where rptEESTMT_A is the actual...
3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
2
by: Timppa | last post by:
Hi, I have Access 2000 and now I'm converting .mdb database to .adp and Sql Server 2000. In old .mdb application I have a query which handles msysobjects table (reading forms and reports...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
12
by: Tony Ciconte | last post by:
We are evaluating the prospect of integrating and/or using Crystal Reports with some of our current products. Some of these are still in Access 97 and are running well. Since we cannot include the...
16
by: JoeW | last post by:
I'm utilizing a database that I created within MS Access within a program I've created in VB.NET. I am using the VB front end to navigate the information, but want to be able to print a report,...
0
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,...
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: 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$) { } ...
0
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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...

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.