H
HughMcMenamin via AccessMonster.com
It splits the first record and pastes it to the 2nd table, but stops after
the first ;
Then it goes to the next record and splits it's contents too in the same way.
It just pastes the 1st part of the split into the 2nd table.
If I remove the Loop and un-comment the two '****** lines, then it splits the
first record of the field, and puts all the 'splits' into table 2. I am try
to get it to do both.
(i.e. Split each record and populate Table2, move to the next record and do
the same ...until the end of file. Can anyone help me combine the below ....I
can only manage one or the other!! Thanks!
Public Function testCDO()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim araAddress() As String
Dim intI As Integer
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Table1")
Set rs2 = db.OpenRecordset("Table2")
rs1.MoveFirst
Do While Not rs1.EOF
araAddress = Split(rs1!Field1, ";")
' ******For intI = 0 To UBound(araAddress) - 1
rs2.AddNew
rs2!Field1 = araAddress(intI)
rs2.Update
rs1.MoveNext
Loop
' ******Next intI
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Function
the first ;
Then it goes to the next record and splits it's contents too in the same way.
It just pastes the 1st part of the split into the 2nd table.
If I remove the Loop and un-comment the two '****** lines, then it splits the
first record of the field, and puts all the 'splits' into table 2. I am try
to get it to do both.
(i.e. Split each record and populate Table2, move to the next record and do
the same ...until the end of file. Can anyone help me combine the below ....I
can only manage one or the other!! Thanks!
Public Function testCDO()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim araAddress() As String
Dim intI As Integer
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Table1")
Set rs2 = db.OpenRecordset("Table2")
rs1.MoveFirst
Do While Not rs1.EOF
araAddress = Split(rs1!Field1, ";")
' ******For intI = 0 To UBound(araAddress) - 1
rs2.AddNew
rs2!Field1 = araAddress(intI)
rs2.Update
rs1.MoveNext
Loop
' ******Next intI
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Function