
Accessing Access report via VB
Your question has been discussed here last month here. If you can search
posts of this group on Oct. 9 to Oct 12 on subject "VB6 Frontend - Access
2002 Displaying Reports".
In case you don't find it, here is the copy of my first post to the question
(between 2 "********" lines):
**********************************************************
It seems that the database you are using is Access. With Access you can
design a better report than what you can with Data Report, coming with VB.
Unless your report is very simple, or you don't mind if it looks not so
great.
In your case, you have reports pre-built in Access and you want the report's
RecordSource can be changed dynamically in a VB program. Yes, it is doable.
Set reference to Access object library in your VB project, then you can
manipulate Access report object from VB project.
Tip:
If you want dynamically Report's desgn in Access from VB code, you need open
the report in design view first, then open it in preview view or normal
(printing) view. The codes looks like:
Dim appAccess as Access.Application
set appAccess=Getobject("Access.Application") ' OR
CreateObject("Access.Application")
......
appAccess.DoCmd.OpenReport "myReport", acViewDesign
......
'Do some report change
......
appAccess.DoCmd.OpenReport "myReport", acViewPreview 'OR acViewNormal
......
Quote:
> Hi all,
> I have built queries in Access that require the user to supply
> information. I have tried to open the reports (that are based on those
> queries) directly from within VB to no avail, so I translated my queries
to
> SQL and added a new Command to my Data Enviroment to base a Data Report in
> VB on.
> Now when I run my query it halts stating that the information I am
> requesting from the user has no default value. It seems to me that SQL is
> treating my prompt as a variable.
> My questions are these:
> Is there any way to prompt the user for the required data that my queries
> require from VB so that I can call my Access reports and display them to
> the user upon request?
> Is it a better idea to use my SQL command in Data Enviroment to run the
> queries and design my reports in VB - Data Reports?
> If it IS a better idea to use Data Reports how do I prompt a user for data
> in SQL in order to supply my query with the data it requires to execute?
> I'd be happy to supply any information that you may require to help me
> resolve this problem.
> Any help would be greatly appreciated,
> Bent
***********************************************************
Quote:
> I have designed a number of reports in an Access 97/2000 database. I
> would like to run these reports via VB 6.0. For example I would
> design some type of report module in the VB app that allows the user
> to enter a selection criteria and run the report.
> Any help on this would be great.
> Thanks
> Matt