How to show MS access two tables in one data report using visual basic 6

Display two tables of data in single data report using visual basic

Are you working on the database program and looking for the program it will show ms access to two tables in one data report using visual basic 6. For creating this program we are going to use the inner join query of MS access. I hope you know about the inner query, if you don’t know that then don’t worry below we are going to discuss the inner join query briefly. If you already know how to display a record in a data report in vb6 then maybe you have a basic idea about the database then this program will be easy to understand and you can get the proper knowledge for how to show ms access to two tables in one data report using visual basic 6.0


Source code for show MS access two tables in one data report using visual basic 6 

'Write this code on the Module for database connection

Public con As New ADODB.Connection
Public rs As New ADODB.Recordset

Sub main()
con.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & App.Path & "\mydatabase.mdb;"
con.Open
Form1.Show
End Sub


'Write this code on the form

Sub filllistview()
rs.Open "select * from table1 inner join table2 on table1.id= table2.id", con, 3, 2
If Not rs.EOF Then
ListView1.ListItems.Clear
rs.MoveFirst

Do While Not rs.EOF
Set Item = ListView1.ListItems.Add(, , rs!Name)
Item.SubItems(1) = rs!country
Item.SubItems(2) = rs!age
rs.MoveNext
Loop
Else
ListView1.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub

Private Sub Form_Load()
Me.filllistview
End Sub

For more details you can watch the video tutorial



Post a Comment

0 Comments