Split not working correctly

  • Thread starter HughMcMenamin via AccessMonster.com
  • Start date
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
 
K

Klatuu

Where do you expect to find the ";" character for the split to split on?
Here is a simpler method:

Do While Not rs1.EOF
rs2.AddNew
For intI = 0 To rs1.Fields.Count - 1
rs2.Fields(intI) = rs1.Fields(intI)
Next intI
rs2.Update
rs1.MoveNext
Loop

If that is not what you are trying to do, post back with more detail, please
 
S

Shamrox via AccessMonster.com

That's good - Thanx
Where do you expect to find the ";" character for the split to split on?
Here is a simpler method:

Do While Not rs1.EOF
rs2.AddNew
For intI = 0 To rs1.Fields.Count - 1
rs2.Fields(intI) = rs1.Fields(intI)
Next intI
rs2.Update
rs1.MoveNext
Loop

If that is not what you are trying to do, post back with more detail, please
It splits the first record and pastes it to the 2nd table, but stops after
the first ;
[quoted text clipped - 40 lines]
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top