Dear all,
I am trying to update a table with fields from an array. The array works fine, I can test it with msgboxes. However when I try to then insert the array values into a table the array the field names get pasted in instead. My code is below - any thoughts where I have gone wrong anyone?
[
]
If I remove the ' from the MyArray(0) or use (MyArray(0)) I get an error message: 'Run time error 3085. Undefined function 'MyArray' in expression.
If I change to MyArray.Fields( 0)again the field name is pasted not the field value.
Any help appreciated.
Thanks
I am trying to update a table with fields from an array. The array works fine, I can test it with msgboxes. However when I try to then insert the array values into a table the array the field names get pasted in instead. My code is below - any thoughts where I have gone wrong anyone?
[
Code:
Private Sub cmdSplit_Click() Dim MyString, MyArray, Msg MyString = Me!txtSearch MyArray = Split(MyString, , -1, 1) Dim mySQL As String mySQL = "insert into tblSearchStock (text1, text2, text3)" mySQL = mySQL + "values ( 'MyArray(0)', 'MyArray(1)', 'MyArray(2)')" DoCmd.RunSQL mySQL End Sub
If I remove the ' from the MyArray(0) or use (MyArray(0)) I get an error message: 'Run time error 3085. Undefined function 'MyArray' in expression.
If I change to MyArray.Fields( 0)again the field name is pasted not the field value.
Any help appreciated.
Thanks
Comment