B
B
bender30002016-10-14 08:17:34
Visual Basic
bender3000, 2016-10-14 08:17:34

How to fix a syntax error?

I'm trying to add codes from a list to another table. Since you need to enter all the elements, I use a loop:

Private Sub save_marks_Click()
Dim strSQL As Variant
For Each strSQL In criteria.ListIndex
strSQL = " Insert Into marks(userid, finalgrade, criteriaid) values ('" & Me.student & "', '" & Me.mark & "', '" & Me.criteria & "');"
CurrentProject.Connection.Execute (strSQL)
Next strSQL
MsgBox ("Added!")
End Sub

It gives an error that For Each is only for objects and arrays. Tell me how to implement correctly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question