Hello experts,
Table1 has one field "Objectives". Table2 has one field too "ObjectivesBroken". Value for "Objectives" field is 'primary education, health and sanitation, vocational training'.
I am trying to run below code to break the value of "objectives" field after each coma and append the result to "ObjectivesBroken" field in Table2. I had tried it before and worked so well. This time I can't figure out what error do I make that it gives me this message "Number of query values and destination fields are not the same".
Much appreciate your help.
Hamdard
Table1 has one field "Objectives". Table2 has one field too "ObjectivesBroken". Value for "Objectives" field is 'primary education, health and sanitation, vocational training'.
I am trying to run below code to break the value of "objectives" field after each coma and append the result to "ObjectivesBroken" field in Table2. I had tried it before and worked so well. This time I can't figure out what error do I make that it gives me this message "Number of query values and destination fields are not the same".
Code:
Private Sub Command0_Click()
Dim MyArray As Variant
Dim rs As DAO.Recordset
Dim i As Integer
Dim strSQL As String
Set rs = CurrentDb.OpenRecordset("Table1")
With rs
.MoveFirst
Do While Not .EOF
MyArray = Split(!Objectives, ",")
For i = 0 To UBound(MyArray)
strSQL = "Insert Into Table2 (ObjectivesBroken) Values(""" _
& """, """ & MyArray(i) & """);"
CurrentDb.Execute strSQL
Next i
.MoveNext
Loop
End With
End Sub
Much appreciate your help.
Hamdard