Hi everyone!
Iam trying to find answers for maybe simple thing but with no results yet ...
I you can help me it will be great! Thanks! Jiri
I have two tables :
TAB1 :
id filedX
1 AAA
2 BBB
3 CCC
TAB2 :
id fieldY fieldZ
1 aaa1 AAA
2 aaa2 AAA
3 aaa3 AAA
4 bbb1 BBB
5 bbb1 BBB
And I need to gain this result in one text string:
AAA (aaa1;aaa2;aaa3) ; BBB (bbb1;bbb2) ; CCC
I started with this code :
In red colour is my problem - how to do relation between recordsets ...
Iam trying to find answers for maybe simple thing but with no results yet ...
I you can help me it will be great! Thanks! Jiri
I have two tables :
TAB1 :
id filedX
1 AAA
2 BBB
3 CCC
TAB2 :
id fieldY fieldZ
1 aaa1 AAA
2 aaa2 AAA
3 aaa3 AAA
4 bbb1 BBB
5 bbb1 BBB
And I need to gain this result in one text string:
AAA (aaa1;aaa2;aaa3) ; BBB (bbb1;bbb2) ; CCC
I started with this code :
Code:
Private Sub Příkaz1_Click()
Dim db As DAO.Database
Dim r1, r2 As DAO.Recordset
Dim tex1 As String
Set db = CurrentDb
Set r1 = db.OpenRecordset("SELECT * FROM TAB1")
Set r2 = db.OpenRecordset("SELECT * FROM TAB1 RIGHT JOIN TAB2 ON TAB1.id = TAB2.fieldZ WHERE (((TAB2.fieldZ)=[COLOR="Red"]XXXXXXXX[/COLOR]))")
tex1 = ""
tex2 = ""
r1.MoveFirst
Do While Not r1.EOF
tex1 = tex1 + " ; " + r1!fieldX
r2.MoveFirst
Do While Not r2.EOF
tex2 = tex2 + ";" + r2!fieldY
r2.MoveNext
Loop
tex1 = tex1 + "(" + tex2 + ")"
r1.MoveNext
Loop
MsgBox (tex1)
End Sub
In red colour is my problem - how to do relation between recordsets ...