Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show reportnames from Acces DB

Status
Not open for further replies.

sbdproj

Programmer
Sep 22, 2003
22
NL
Hi,

In my program I use an Access(2003) Database. I've made some reports in it which the user can open within my program.
Now I want to fill a combobox with the reports from the database at the start of the program. This way I don't have to program the reports in the code of my program, but I can fill the combobox dynamically.

I have made 2 reports but I can't get the combobox filled. Does anyone know how to do This?

This is the code I have until now:
I use this reference:
Microsoft Access 11.0 Object Library
As imports I have this:
Imports Microsoft.Office.Interop.Access

Code:
Dim i as integer
Dim Accessapp As New Microsoft.Office.Interop.Access.Application()

Accessapp.OpenCurrentDatabase(DatabaseDir)
for i=0 to Accessapp.Reports.Count-1
combobox1.add(Accessapp.Reports.Item(i))
next i
Accessapp = Nothing
 
reports only retruns the open reports not the closed ones so in your case nothing

make a querie with this select statement

Code:
SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32764))
ORDER BY MSysObjects.Name;

and then put those in your combobox via the

combobox1.items.add method.

BTW the access mdb needs to have hidden objects and system objects turned on. You can find it under tools options when you are in the main window.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
thanks for the help. I didn't know I could use these objects in Access to get information like this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top