การเปรียบเทียบค่า 2 ตาราง 2 ข้อมูล ให้ตรงกันบน Form หลังจากการกรอกข้อมูล


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

10 ก.ย. 63 , 10:18:38
อ่าน 707 ครั้ง
การเปรียบเทียบค่า 2 ตาราง 2 ข้อมูล ให้ตรงกันบน Form หลังจากการกรอกข้อมูล


ถ้าเช็ตแค่ 1 ข้อมูลทำได้ แต่ถ้า 2 ข้อมูลครับ รบกวนช่วยแก้ไขโค้ดด้วยครับ

Private Sub Text97_AfterUpdate()
 Dim chk As Variant
chk = DLookup("[Barcode PCB]", "[In Process oki]", "[Barcode PCB] = '" & Me.Text97 & "'")
    If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล In Process กรุณาตรวจสอบ"
       Me.Undo
        Exit Sub
    End If
    End Sub

ขอบคุณครับ

 

10 ก.ย. 63 , 10:28:34
ตอบกลับ #1

PNR

Private Sub Text97_AfterUpdate()
CheckData
End Sub

Private Sub ชื่อtextboxของTagNoBarcode_AfterUpdate()
CheckData
End Sub


Private Sub CheckData
Dim chk,chk2 As Variant
IF not isnull(Me.Text97) And  not isnull(Me.ชื่อtextboxของTagNoBarcode) then
chk = DLookup("[Barcode PCB]", "[TableA]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode] = '" & Me.[ชื่อtextboxของTag No Barcode] & "'")
chk2 = DLookup("[Barcode PCB]", "[TableB]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode] = '" & Me.[ชื่อtextboxของTag No Barcode] & "'")
    If IsNull(chk) And IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูลในทั้งสองตาราง กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล In TableA กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูล In TableB กรุณาตรวจสอบ"
       Me.Undo
    Else If Not IsNull(chk) and Not IsNull(chk2) Then
      MsgBox "มีข้อมูลทั้งสองชุด"
    End If
end if
End Sub
« แก้ไขครั้งสุดท้าย: 10 ก.ย. 63 , 11:05:12 โดย PNR »
Time to stop for me  :dizzy:
 

10 ก.ย. 63 , 10:56:57
ตอบกลับ #2
ขอบคุณมากครับ เดี๋ยวขอนำไปทดสอบก่อนครับ

 

10 ก.ย. 63 , 11:19:51
ตอบกลับ #3
อีกอย่างครับ ถ้าไม่มีช่องให้กรอก Tag No Barcode หละครับควรเป็นแบบนี้เปล่าครับ หรือ ตรงตาราง Tag No Barcode เป็น Autonumber

Private Sub Text97_AfterUpdate()
Dim chk, chk2 As Variant
If Not IsNull(Me.Text97) And Not IsNull[Tag No Barcode] Then
chk = DLookup("[Barcode PCB]", "[In Process]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode] ")
chk2 = DLookup("[Barcode PCB]", "[Out Process]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode]")
    If IsNull(chk) And IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูลในทั้งสองตาราง กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล In Process oki กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูล Out Process oki กรุณาตรวจสอบ"
       Me.Undo
    Else If Not IsNull(chk) and Not IsNull(chk2) Then
      MsgBox "มีข้อมูลทั้งสอง Process กรุณาตรวจสอบ"
    End If
End If
    End Sub

 

10 ก.ย. 63 , 11:40:34
ตอบกลับ #4

PNR

แสดงว่า Tag No Barcode เป็น Number ต้องใส่แบบนี้

Private Sub Text97_AfterUpdate()
Dim chk, chk2 As Variant
If Not IsNull(Me.Text97) Then
chk = DLookup("[Barcode PCB]", "[In Process]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode] = " & [Tag No Barcode] & "")
chk2 = DLookup("[Barcode PCB]", "[Out Process]", "[Barcode PCB] = '" & Me.Text97 & "' And [Tag No Barcode] = " & [Tag No Barcode] & "")
    If IsNull(chk) And IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูลในทั้งสองตาราง กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk) Then
       MsgBox "ไม่มีข้อมูล In Process oki กรุณาตรวจสอบ"
       Me.Undo
    Else If IsNull(chk2) Then
       MsgBox "ไม่มีข้อมูล Out Process oki กรุณาตรวจสอบ"
       Me.Undo
    Else If Not IsNull(chk) and Not IsNull(chk2) Then
      MsgBox "มีข้อมูลทั้งสอง Process กรุณาตรวจสอบ"
    End If
End If
    End Sub
Time to stop for me  :dizzy:
 

10 ก.ย. 63 , 12:10:43
ตอบกลับ #5
ขอบคุณครับ

 


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


 

Sitemap 1 2 3 4 5