For this tutorial i have used a Microsoft Access database with two tables 'Categories' and 'Products' with parent-child relationship between them. The fields in each table are shown below
Categories
Products
The two tables should have a parent-child relationship. The relation between the two tables i have created is shown below
This is all we need from Microsoft Access. Now start a new data project in Visual Basic. You should have a form and data report added to your project.
Open the report right click in the white area and select 'Insert Group Header/Footer'

Add fields from the parent table in the group header section and fields from the child table in the data section of the report. Set the [DataMember] property of products field to "Products". Leave the [DataMember] property of parent fields to blank. The report should look similar to the one shown below.

Open the form code window and add the following code
Dim cn As New ADODB.Connection
Private Sub Command1_Click()
Dim rsTemp As New ADODB.Recordset
rsTemp.Open "SHAPE {Select Categories.CategoryId,Categories.CategoryName from Categories} as Categories APPEND ({Select * from Products} Relate CategoryId to CategoryId) as Products", cn
Set rptProducts.DataSource = rsTemp
rptProducts.WindowState = vbMaximized
rptProducts.Show
End Sub
Private Sub Form_Load()
cn.ConnectionString = "Provider=MSDataShape.1;Data Provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path & "\db.mdb"
cn.Open
End Sub
What the above code does?
First of all you need to add "Provider=MSDataShape.1;" to the connection string otherwise the Shape command in the query will not work. The Shape command is the crux of creating group reports in visual basic. It shapes up hierarchal data and formats it to be used by the data report. Thats all in this tutorial. If you have any problems please discuss below and also download the files included with this tutorial
Download Sample Code
This tutorial is about creating buttons which look similar to Facebook buttons. . Read More Facebook Button CSS