แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - honeypiez19

หน้า: [1]
1
ค่าของช่องแรกออกเป็น 20 มันต้องเป็น 22 ค่ะ T^T ' ช่วยด้วยค่าา #มือใหม่หัดเขียน  :cry: :cry:



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

2
มี Table 2 Table

Table แรกชื่อ import_data (import เป็นไฟล์ Excel เข้า)
Table สองชื่อ tblTransaction (สำหรับประมวลผล)


ช่อง Field ชื่อ iCustPartsCode เราอยากส่งข้อมูลไป Table tblTransaction ช่อง Field tCustItem
ต้องเขียนยังไงคะ T^T มือใหม่หัดเขียนค่ะ ช่วยหน่อยนะคะ -/\- '

หน้า: [1]