Can Not Get Split Code to Loop Through Form (1 Viewer)

ed coleman

Registered User.
Local time
Today, 02:47
Joined
Nov 8, 2012
Messages
44
I have a table where there are various size measurements in one textbox. They are delimited with an x and I have managed to find code to split them into columns on the form and, hence, the table itself. My problem is that I cannot get VBA code to loop and perform the same operation on each record.

The code works on the first record and if I put my cursor in a blank cell for the next record and hit the command button, it will populate that record, but will not loop through the record set.

Any assistance with my problem is appreciated.

The code that I am currently using is below as well as the form that I have attached.

Code:
Private Sub Command39_Click()
Dim v        As Variant
Dim sOne     As Variant
Dim i        As Integer

Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("tblforsplit")
Do While Not rs.EOF
'for width only
v = Split(Me.WIDTH_SCORE, " x ")
i = 0
For Each sOne In v
   i = i + 1
   Me("w" & i) = sOne

Next

rs.MoveNext
Loop
Refresh
rs.Close

End Sub
 
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:47
Joined
Jan 20, 2009
Messages
12,852
Me("w" & i) = sOne
DoCmd.GoToRecord , , acNewRec
Next
 

ed coleman

Registered User.
Local time
Today, 02:47
Joined
Nov 8, 2012
Messages
44
Thanks Galaxiom, but this did not do the trick. I have attached a screen print showing the error message and the fact that this added records. What I need to do is go to each record and run the split code to get the width_score broken out into individual columns for each record.

Regards Ed
 
Last edited:

Users who are viewing this thread

Top Bottom