ขอวิธีเพิ่มข้อมูลในตาราง โดยเอาข้อมูลจาก tableอื่นที่ link กัน


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

16 ก.ค. 63 , 13:24:35
อ่าน 587 ครั้ง

kunlek

จากกระทู้หัวข้อเรื่องดึงราคาฯ  Mainforms Voucehr_s (table voucher_s มี ฟิลด์ cust_id) และ SubForms fsale(table fsale เดิมไม่มี ฟิลด์ cust_id มาเพิ่มฟิลด์ cust_id ภายหลัง )   ผมขอวิธีจะเอาข้อมูลจาก cust_id ของ voucher_s ไปใส่ใน ฟิลด์ใหม่ cust_id ของ fsale โดยผูกกันด้วย voucher_s_id

 

16 ก.ค. 63 , 15:36:20
ตอบกลับ #1

PNR

เพิ่มเติมโค้ดอีกหน่อยก็ได้เลยครับ
โดยที่ฟอร์ม Fsale ที่เป็น ซัฟฟอร์ม ให้มี textboxที่เป็นฟิลล์ Cust_id และชื่อ Cust_id ด้วยนะครับ

Private Sub good_id_AfterUpdate()
Call CheckS_Price
End Sub
Sub CheckS_Price()
Dim LastDate As String
Dim strPurchase_history As String
If Not IsNull(Me.date_sale) And Not IsNull(Me.good_id) And Not IsNull(Forms!ACC_บันทึกขายสินค้า!Txtcust_id) Then
strPurchase_history = Nz(DLookup("[cust_id]", "[tblF_sale]", "[goods_id] = '" & good_id & "' And [cust_id] =" & Forms!ACC_บันทึกขายสินค้า!Txtcust_id & ""), 0)

LastDate = Nz(DLast("date_sale", "[tblF_sale]", "[goods_id] = '" & good_id & "' And [cust_id] =" & Forms!ACC_บันทึกขายสินค้า!Txtcust_id & ""), 0)
Me.s_price = Nz(DLookup("[s_price]", "[tblF_sale]", "cstr([date_sale]) ='" & LastDate & "' And [goods_id] ='" & good_id & "' And [cust_id] =" & Forms!ACC_บันทึกขายสินค้า!Txtcust_id & ""), 0)
End If
If Not IsNull(Forms!ACC_บันทึกขายสินค้า!Txtcust_id) Then
Me.cust_id = Forms!ACC_บันทึกขายสินค้า!Txtcust_id
End If

End Sub
Time to stop for me  :dizzy:
 

16 ก.ค. 63 , 15:59:35
ตอบกลับ #2

kunlek

ข้อมูลเก่า cust_id จาก voucher_s ไม่ไปครับ แต่ entry ปัจจุบันมี cust_id ทั้ง 2 table ครับ

 


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


 

Sitemap 1 2 3 4 5