Link to home
Start Free TrialLog in
Avatar of matrix717
matrix717

asked on

How to make Reports ?

I 'm using Visual Studio 6 and an Access 2000 database, how can I make a simple report from VB using the info from some tables of access?

Please gime me step by spet instruction because I really dont know hot to do this...

Thanks a lot
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

You can use the Access report engine to build your report and print your view/print report from VB.

Use this code:



Private Sub Command1_Click()
   Dim ac As Access.Application
   Set ac = New Access.Application
   ' open the database.
   ' replace the "c:\myDir\myDBFileName.mdb" below with your
   ' database file name
   ac.OpenCurrentDatabase "c:\myDir\myDBFileName.mdb"
   ' uncomment the line below if you want to see Print Preview
   ' ac.Visible = True
   ' replace the acViewNormal below with acViewPreview
   ' if you want to see Print Preview
   ac.DoCmd.OpenReport "MYREPORT", acViewNormal
   ' delete the line below if you want to see Print Preview
   ac.CloseCurrentDatabase
End Sub
Notice that users to whom you install the application will require Access to be installed on their PC.
Simply use the data report that is bundled in vb

Very easy to use. See MSDN on how to get started with data reports. MSDN has step by step information.

Ajay Chadha ..... :-)
ASKER CERTIFIED SOLUTION
Avatar of AJAY CHADHA
AJAY CHADHA
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1- Add Data Environment and Data Report into your project (click Project menu, you'll see)
2- Right click on Connection1 object under Connections in Data Environment and set a source to use as database file. and also set the properties like permissions and passwords (if a password exists).
3- Right click on Commands and Add Command. Select a connection in the properties window. And then select a source like table, query or create a custom SQL text in SQL Statement. (if your connection is ok then you will see tables in Object Name combobox if you select a table type as a database object. (If command has a valid source then you can see the objects listed under Command1 name which you created.)
5- Goto Data Report design view and set your Data Environment as Data source and your Command as Data Member.
6- Insert a TextBox and Set DataMember as your Command1 and set DataField as a field name listed in related combo in properties window.

Now run it by using;

DataReport1.Show

in a command button to show the report.

This is the basics to use data reports integrated in Visual Basic. But you will see it would be disaster to use Data Reports which is in Visual Basic to create advanced reports. So i suggest what emoreau and chadhaajay said about using Access Reports within VisualBasic.

Of course Crystal Reports would be great to create advanced reports and integrate it into your application.


Good Luck!

suat






Avatar of matrix717
matrix717

ASKER

Hi chadhaajay, Thanks a lot 4 for help. Also to smozgur but chadhaajay was first.

Chadhaajay, where to get information about making reports with Crystal Reports?