R
rslowin
I have three tables
TStudents ( idStudent PK, Name, Languages )
TALanguagesStudents( idStudent, idLanguage )
TLanguages ( idLanguage PK, Language)
I need to concatenate all languages known by a Student in a field
TStudents.Languages
Here is code in VBA
Sub pre()
Dim dbs As Database
Dim rst, rst0, rst1 As Recordset
Dim ids, idl, str_pom As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TStudents")
With rst
.MoveFirst
While Not .EOF
str_pom = ""
ids = !idStudent
Set rst0 = dbs.OpenRecordset("SELECT * FROM TALanguagesStudents
WHERE idStudent = " & Trim(Str(ids)))
With rst0
.MoveFirst
While Not .EOF
idl = !idLanguage
Set rst1 = dbs.OpenRecordset("SELECT
TLanguages.Language FROM TLanguages INNER JOIN
TALanguagesStudents ON TLanguages.idLanguage =
TALanguagesStudents.idLanguage WHERE
(((TALanguageStudents.idStudent)=" & Trim(Str(ids)) &
") AND ((TALanguageStudents.idLanguage)=" &
Trim(Str(idl)) & "))")
str_pom = str_pom + " " + rst1!Language
.MoveNext
Wend
End With
.Edit
!Languages = str_pom
.Update
.MoveNext
Wend
End With
End Sub
The problem is in a line Set rst1 = dbs......
An error #13 Type mismatch
Can you help me, please.
Regards
Rafi
TStudents ( idStudent PK, Name, Languages )
TALanguagesStudents( idStudent, idLanguage )
TLanguages ( idLanguage PK, Language)
I need to concatenate all languages known by a Student in a field
TStudents.Languages
Here is code in VBA
Sub pre()
Dim dbs As Database
Dim rst, rst0, rst1 As Recordset
Dim ids, idl, str_pom As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TStudents")
With rst
.MoveFirst
While Not .EOF
str_pom = ""
ids = !idStudent
Set rst0 = dbs.OpenRecordset("SELECT * FROM TALanguagesStudents
WHERE idStudent = " & Trim(Str(ids)))
With rst0
.MoveFirst
While Not .EOF
idl = !idLanguage
Set rst1 = dbs.OpenRecordset("SELECT
TLanguages.Language FROM TLanguages INNER JOIN
TALanguagesStudents ON TLanguages.idLanguage =
TALanguagesStudents.idLanguage WHERE
(((TALanguageStudents.idStudent)=" & Trim(Str(ids)) &
") AND ((TALanguageStudents.idLanguage)=" &
Trim(Str(idl)) & "))")
str_pom = str_pom + " " + rst1!Language
.MoveNext
Wend
End With
.Edit
!Languages = str_pom
.Update
.MoveNext
Wend
End With
End Sub
The problem is in a line Set rst1 = dbs......
An error #13 Type mismatch
Can you help me, please.
Regards
Rafi