472,805 Members | 1,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 3199
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,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.