Open Relational Database

RAYMOND HJ
10-19-2000, 08:47 AM
Hallo HI...
I have a problem to display record in a relational database.

I'm using Microsoft Acess database ( 2 tables )

Table 1: BOOK ( contains 3 fields )

Title_Id (AutoNumber - Primary Key)
Title (Text)
Author_Id (Number - Key Field - related : one to many)

Table 2: AUTHORS ( contains 2 fields )

Author_Id (AutoNumber - Primary Key)
Name (Text)

Here is the code:

Dim db As Database
Dim RS1 As Recordset, RS2 As Recordset

Set db = Workspaces0).OpenDatabase "C:BOOKS.MDB")
Set RS1 = db.OpenRecordset("BOOK", dbOpenTable)
Set RS2 = db.OpenRecordset("AUTHORS", dbOpenTable)

do while NOT RS2.Eof
msflex1.col = 0
msflex1.text = RS2!TITLE
msflex1.col = 1
msflex1.text = RS1!NAME ' problem rise here
RS2.movenext
loop

The problem : I cannot display author Name from AUTHORS TABLE related to the BOOK record. I can see only the name from the first record only (AUTHORS TABLE)

Thank you for your help...

PWNettle
10-19-2000, 02:36 PM
You're not opening your recordsets with any kind of relationship between them. One easy solution would be to make a query in Access that combines the data the way you want it...then hit that query with one recordset from VB.

Good luck,
Paul

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum