ต้องการดึงข้อมูลรายการก่อนหน้ามาครับ


0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

07 ก.ย. 66 , 11:14:34
อ่าน 248 ครั้ง

Wisarut007

  • สมาชิกไท.Access
  • กระทู้: 2

  • ขอบคุณ ไท.Access

    • ดูรายละเอียด

สวัสดีครับ ขอสอบถามวิธีการ Query

- ต้องการดึงข้อมูลรายการก่อนหน้า ให้ออกมาตามคอลัมน์ Amount_New ตามตัวอย่างครับ


 

08 ก.ย. 66 , 00:32:08
ตอบกลับ #1

nonc31

: ต้องการดึงข้อมูลรายการก่อนหน้ามาครับ
« ตอบกลับ #1 เมื่อ: 08 ก.ย. 66 , 00:32:08 »
Function updateAmountNew()
   On Error GoTo erC

        Dim db As Database
        Dim rstOut As Recordset
        Dim f As Field
        Dim taw As String
            Set db = CurrentDb
            Set rstOut = CurrentDb.OpenRecordset("ตาราง/คิวรี่")
           
        rstOut.MoveFirst
        Do Until rstOut.EOF
            If InStr(rstOut.Fields("DebitCredit").Value, "Credit") > 0 Then
                taw = rstOut.Fields("Amount").Value
            End If
        For Each f In rstOut.Fields
            DoCmd.SetWarnings False
            rstOut.Edit
            rstOut![AmountNew] = taw
            rstOut.Update
        Next
            rstOut.MoveNext
            If InStr(rstOut.Fields("DebitCredit").Value, "Credit") <= 0 Then
                taw = taw
            Else
                taw = rstOut.Fields("Amount").Value
            End If
        Loop
       
            rstOut.Close
            Set db = Nothing

Exit Function

erC:
    Select Case Err
        Case 0
        Case 3021
            Exit Function
        Case Else
            MsgBox "Function updateAmountNew" & " > " & Err.Description & " รหัส " & Err.Number
    End Select
End Function

 


บอร์ดเรียนรู้ Access สำหรับคนไทย


 

Sitemap 1 2 3 4 5