myTable
+-----------+-----------------------+
| Field1 | Field2 |
+-----------+-----------------------+
| AAA | Value1, Value2,Value3 |
+-----------+-----------------------+
| BBB; CCC | Value4, Value5 |
+-----------+-----------------------+
| DDD | Value6 |
+-----------+-----------------------+
Select Field1, Split(Field2, ",") As SplitField2
From myTable
+-----------+-------------+
| Field1 | SplitField2 |
+-----------+-------------+
| AAA | Value1 |
+-----------+-------------+
| AAA | Value2 |
+-----------+-------------+
| AAA | Value3 |
+-----------+-------------+
| BBB; CCC | Value4 |
+-----------+-------------|
| BBB; CCC | Value5 |
+-----------+-------------+
| DDD | Value6 |
+-----------+-------------+
Note that, the function 'Split' is what I want to program. But so far, I haven't got any idea how to immplement it.
I'm inspired by the post: Split Field Into Multiple Records in Access DB . It has given a useful way to create new records. Under the guidance of this post, I have written a similar function called SplitField. With the help of data macros in MS Access, the function SplitField can keep a new table named myNewTable having the same records as myTable (Of course, With Field2 being split). But in this way, I have to create new tables, write a new data macro to pass table name, field name, current record and etc to the function SplitField.
Is it able to program a function named "Split" and use it in the way shown at the beginning of this post? With this function, users may split field more efficiently. Users can even split more than one field at the same time, for instance.
Select Split(Field1, ";") As SplitField1, Split(Field2, ",") As SplitField2
From myTable
+---------------+-------------+
| SplitField1 | SplitField2 |
+---------------+-------------+
| AAA | Value1 |
+---------------+-------------+
| AAA | Value2 |
+---------------+-------------+
| AAA | Value3 |
+---------------+-------------+
| BBB | Value4 |
+---------------+-------------+
| BBB | Value5 |
+---------------+-------------+
| CCC | Value4 |
+---------------+-------------+
| CCC | Value5 |
+---------------+-------------+
| DDD | Value6 |
+---------------+-------------+