The Database is Access, I am accessing it with DAO ( I think, at least I define it as below)
Dim db As DAO.Database 'Database Space
Dim Tracks As DAO.Recordset 'Record Set space for tracks
Dim Albums As DAO.Recordset 'Record Set space for Albums
I am trying to loop thru the database and extract data elements from both joined tables. It works great for the first record but the rest don’t have the data from the albums (ie.albums.position and albums.player)table. The code may not be syntax perfect but I think anyone will get the idea of the logic. The logic works, I display all the records but only good data from the tracks table.
I don't pretend to be a VB expert. To many options..
Set Tracks = db.OpenRecordset("Select tracks.title,tracks.id,albums.position, albums.player FROM Tracks INNER JOIN albums ON tracks.cdjid=albums.cdjid ORDER BY tracks.title"
For i = 1 To max 'max setup prior logic for tracks table
titlesv = Tracks("Title"
IDsv = Tracks("ID"
titlelen = Len(titlesv)
Artistlen = Len(Artistsv)
IDlen = Len(IDsv)
Playersv = Albums("CDJID"
Positionsv = Albums("Position"
If titlelen > 50 Then titlelen = 50
If Artistlen > 40 Then Artistlen = 40
displayline = (titlesv + Trim(Left(stars, (50 - titlelen)))) + Positionsv + " ID" + IDsv
lstdata.AddItem displayline
NextRecordset 'Move to the next record
Next i
Dim db As DAO.Database 'Database Space
Dim Tracks As DAO.Recordset 'Record Set space for tracks
Dim Albums As DAO.Recordset 'Record Set space for Albums
I am trying to loop thru the database and extract data elements from both joined tables. It works great for the first record but the rest don’t have the data from the albums (ie.albums.position and albums.player)table. The code may not be syntax perfect but I think anyone will get the idea of the logic. The logic works, I display all the records but only good data from the tracks table.
I don't pretend to be a VB expert. To many options..
Set Tracks = db.OpenRecordset("Select tracks.title,tracks.id,albums.position, albums.player FROM Tracks INNER JOIN albums ON tracks.cdjid=albums.cdjid ORDER BY tracks.title"
For i = 1 To max 'max setup prior logic for tracks table
titlesv = Tracks("Title"
IDsv = Tracks("ID"
titlelen = Len(titlesv)
Artistlen = Len(Artistsv)
IDlen = Len(IDsv)
Playersv = Albums("CDJID"
Positionsv = Albums("Position"
If titlelen > 50 Then titlelen = 50
If Artistlen > 40 Then Artistlen = 40
displayline = (titlesv + Trim(Left(stars, (50 - titlelen)))) + Positionsv + " ID" + IDsv
lstdata.AddItem displayline
NextRecordset 'Move to the next record
Next i