ค่าของช่องแรกออกเป็น 20 มันต้องเป็น 22 ค่ะ T^T ' ช่วยด้วยค่าา #มือใหม่หัดเขียน
Code ค่ะ
Sub TEST1()
Dim CON As ADODB.Connection
Dim TRN As ADODB.Recordset
Dim MST As ADODB.Recordset
Set CON = CurrentProject.Connection
Set TRN = New ADODB.Recordset
Set MST = New ADODB.Recordset
TRN.Open "tblTransaction", CON, adOpenKeyset, adLockOptimistic
Do Until TRN.EOF
cc = ""
tName = TRN!itemname + " "
' Debug.Print InStr(tName, "22")
' Debug.Print tName
For idx = 1 To Len(tName)
If Mid(tName, idx, 1) <> " " Then
cc = cc + Mid(tName, idx, 1)
Else
If Len(cc) > 0 Then
MST.Open "tblKeyword", CON, adOpenStatic, adLockReadOnly
' Do Until MST.EOF
' Debug.Print MST!keyword
If cc = MST!Keyword Then
' MsgBox MST!Category & " --- " & MST!Value
TRN.Update MST!Category, MST!Value
' Debug.Print MST!Category
End If
MST.MoveNext
' Loop
MST.Close
End If
cc = ""
End If
' cc = ""
Next
If TRN!SizeA = TRN!SizeB Then
TRN!Description = TRN!SizeA + " " + TRN!Type + " " + TRN!Type2
' If TRN!Description <> " " Then
' TRN!Description + TRN!SizeA
' Debug.Print TRN!Description
' End If
Debug.Print TRN!Description
ElseIf TRN!SizeA <> TRN!SizeB Then
TRN!Description = TRN!SizeA
TRN!Description2 = TRN!SizeB
Debug.Print TRN!Description + TRN!Description2
End If
TRN.MoveNext
Loop
End Sub