Answer the question
In order to leave comments, you need to log in
How to add the next row in the list to the table through a loop?
From the list I want to bring in order to the table the id rows. I made a loop, but it adds the first row id to all rows of the table.
Private Sub Save_Click()
Dim criteriaSQL As String
With Me.criteria
For i = 0 To .ListCount - 1
If .ListCount > 0 Then
.Selected(i) = True
criteriaSQL = " Insert Into marks(userid, criteriaid, finalgrade) values ('" & Me.student & "', '" & Me.criteria & "', '" & Me.mark & "')"
CurrentProject.Connection.Execute (criteriaSQL)
End If
Next
End With
MsgBox ("Added!")
End Sub
Answer the question
In order to leave comments, you need to log in
Try to make such processes invisible to the user, avoid Selected(i).
If you really want to work through VBA, use
Dim mytab As ADODB.Recordset
Set mytab = New ADODB.Recordset
mytab.Open "Select..." '(тут ваш запрос)'
Do While mytab.EOF = False
'тут что хотите то и тврите с полями mytab!myField'
mytab.MoveNext
Loop
INSERT INTO ТаблицаДляВставки ( ПоляДляВставки через запятую )
SELECT ПоляДоноры
FROM ТаблицыДоноры
WHERE условия выборки можно тащить из формы
ORDER BY сортировочка;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question