Xuân Thanh > 19-06-13, 10:07 AM
Function TachChuoi(ChuoiCanTach As String)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tblTam", dbOpenTable)
If rs.RecordCount > 0 Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From tblTam"
DoCmd.SetWarnings True
End If
Dim Chuoi As String
Dim KQ As String
Dim VT As Integer, i As Integer
KQ = Space(0)
Chuoi = Trim(ChuoiCanTach)
For i = 1 To Len(Chuoi)
VT = InStr(i, Chuoi, ",")
If VT > 0 Then
KQ = KQ & Left(Chuoi, VT - 1)
rs.AddNew
rs.Fields(0) = KQ
rs.Update
Chuoi = Trim(Right(Chuoi, Len(Chuoi) - VT))
KQ = Space(0)
End If
If i = Len(Chuoi) Then
rs.AddNew
rs.Fields(0) = Chuoi
rs.Update
End If
Next
End Function
bomnhauag > 19-06-13, 10:26 AM
Xuân Thanh > 27-06-13, 04:05 PM
Function TachChuoi(ChuoiCanTach As String)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tblTam", dbOpenTable)
If rs.RecordCount > 0 Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From tblTam"
DoCmd.SetWarnings True
End If
Dim i As Long
Dim Chuoi As Variant
Chuoi = Split(ChuoiCanTach, ",")
For i = LBound(Chuoi) To UBound(Chuoi)
rs.AddNew
rs.Fields(0) = Chuoi(i)
rs.Update
Next
End Function