bastanu
AWF VIP
- Local time
- Yesterday, 21:47
- Joined
- Apr 13, 2010
- Messages
- 1,406
Try this update please:
Code:
Public Function Split()
10 On Error GoTo PROC_Error
Dim db As DAO.Database
Dim rsSource As DAO.Recordset
Dim rsOut As DAO.Recordset
Dim SplitToRows() As String
Dim i As Integer
20 Set db = CurrentDb
30 Set rsSource = db.OpenRecordset("Source")
40 Set rsOut = db.OpenRecordset("SerialSplit")
50 If (Not rsSource.BOF And Not rsSource.EOF) Then
60 rsSource.MoveFirst
70 Do Until rsSource.EOF
If IsNull(rsSource!Serial Then GoTo Skip_To_Next
80 SplitToRows = Split(rsSource!Serial, ", ", -1)
90 For i = LBound(SplitToRows) To UBound(SplitToRows)
100 rsOut.AddNew
110 rsOut("Customer Purchase Order") = rsSource("Customer Purchase Order") ' Keep these the same
120 rsOut("Shipped to City") = rsSource("Shipped to City")
130 rsOut("Shipped to State") = rsSource("Shipped to State")
140 rsOut("Item Description") = rsSource("Item Description")
150 rsOut("Quantity") = rsSource("Quantity")
160 rsOut("Unit Price") = rsSource("Unit Price")
170 rsOut("Serial") = SplitToRows(i) ' Data was in one field - split by a comma
180 rsOut.Update
190 Next i '
Skip_To_Next:
200 rsSource.MoveNext
210 Loop
220 Else
230 MsgBox "No Records in Input"
240 End If
250 rsSource.Close
260 Set rsSource = Nothing
270 rsOut.Close
280 Set rsOut = Nothing
290 Set db = Nothing
PROC_Exit:
300 Exit Function
PROC_Error:
310 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in SplitToRows procedure"
320 On Error GoTo 0
Resume PROC_Exit:
End Function