after update
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 273   2
URL.หัวข้อ / URL
after update

Private Sub Form_Load()
Set db = CurrentDb()
Set rs2 = db.OpenRecordset("tblProduct")
rs2.index = "ProductIndex"
Set rs3 = db.OpenRecordset("tblOrder")
rs3.index = "OrderIndex"
Set rs4 = db.OpenRecordset("tblOrderProduct")
rs4.index = "OrderProductIndex"
txtOrderID.SetFocus
End Sub

Private Sub txtOrderID_AfterUpdate()
rs4.Seek "=", txtOrderID.Value
If rs4.NoMatch = False Then
rs4.Fields("Section").Value = txtSection.Value
rs4.Fields("BudgetSect").Value = txtBudgetSect.Value
Else
txtSection.Value = Null
txtBudgetSect.Value = Null
End If
End Sub
โค๊ดดังกล่าวดัดแปลงมาจาก Project จากตาราง tblOrderProduct ผมได้เพิ่ม Section และ BudgetSect ลงใน field name ซึ่ง data type เป็น text ทั้งคู่ แต่ว่าเมื่อลอง update ค่าเก่าลงใน txtOrderID แล้ว ในช่อง txtSection และ txtBudgetSect กลับไม่แสดงค่าใดๆขึ้นมาเลย รบกวนช่วยหาคำตอบด้วยครับ อาจาร์ย

2 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R05748
ลองแบบนี้ครับ

...
If rs4.NoMatch = False Then
txtSection = rs4.Fields("Section")
txtBudgetSect = rs4.Fields("BudgetSect")
Else
...
2 @R05755
ขอบคุณมากครับสำหรับคำแนะนำดีๆ แต่ยังไม่ได้ครับ ยังแสดงช่องว่างเหมือนเดิมครับ ผมจำเป็นต้องกลับไปดูคุณสมบัติของฟิลด์ต่างๆ หรือเปล่าครับ แนะนำด้วยนะครับอาจาร์ย
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0601s