I'm putting together an access database to be used as a reporting function for an online registration database. The online database exports its data into a csv which is then imported into MS Access.
I have four fields that have from 0 to 5 strings of text separated by commas. I need to separate those fields into upto five other fields.
I have created a module with the following code in it to take advantage of the "split" function:
Then in my query to create the five new fields, I have:
When run I get the error:
Run-time error '9'
Subscript out of range
But if I just click on "End" enough times, it does eventually complete. Empty fields have "#Error" in them and where data should be, it does show up.
I am very new to Modules so likely it is the code there, but not 100% sure. Any help would be gratefully appreciated.
I have four fields that have from 0 to 5 strings of text separated by commas. I need to separate those fields into upto five other fields.
I have created a module with the following code in it to take advantage of the "split" function:
Code:
Public Function SplitField(strValue As String, strDelimiter As String, intPartWanted As Integer) As String
SplitField = Split(strValue, strDelimiter, , vbTextCompare)(intPartWanted - 1)
End Function
Code:
Class1: SplitField([Elective Classes - 2nd Session],",",1)
Class2: SplitField([Elective Classes - 2nd Session],",",2)
Class3: SplitField([Elective Classes - 2nd Session],",",3)
Class4: SplitField([Elective Classes - 2nd Session],",",4)
Class5: IIf([class4] Like "*,*",SplitField([Elective Classes - 2nd Session],",",5),Null)
Run-time error '9'
Subscript out of range
But if I just click on "End" enough times, it does eventually complete. Empty fields have "#Error" in them and where data should be, it does show up.
I am very new to Modules so likely it is the code there, but not 100% sure. Any help would be gratefully appreciated.