รวมฟิวส์ Text


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

31 ส.ค. 63 , 14:05:21
อ่าน 848 ครั้ง

naekkhung

รวมฟิวส์ Text
« เมื่อ: 31 ส.ค. 63 , 14:05:21 »

จากรูปจะมี text 4 ตัว
1.Description
2.เบอร์โทร
3.รายงานการติดตาม
4.Total คือเอา 1-3 มารวมกัน
คำถามคือตอนนี้ text รายงานการติดตาม เวลาพิมม์ข้อมูลลงไป ผมอยากให้มัน Update ที่ช่อง Total ทันที ตอนนี้ผมใช้เงื่อนไข After Update อยุ่คือว่ามันต้องคีย์ข้อมูลเสร็จแล้วถึงจะ Update ต้องเขียนแบบไหนครับ



 

31 ส.ค. 63 , 15:24:27
ตอบกลับ #1

UnKnown

: รวมฟิวส์ Text
« ตอบกลับ #1 เมื่อ: 31 ส.ค. 63 , 15:24:27 »
เท่าที่ทราบคือไม่ว่าจะใช้เงื่อนไขไหนก็ต้องพิมพ์เสร็จหรือ Enter ก่อนข้อมูลที่อื่นถึงจะอัพเดทครับ / จะให้เป็นแนวว่าระหว่างพิมพ์ช่องหนึ่งอยู่แล้วให้อีกช่องอัพเดทแบบ Realtime ทันทีเลยทั้งที่ยังไม่ตกลงคงจะไม่มีนะครับ
:ninja:     ลองคิด,ลองทำแนวคนไม่เก่งแอคเซส
หมายเหตุ เพื่อความปลอดภัยโปรดสำรองข้อมูลใว้ก่อนการแก้ไข
 
โพสต์นี้ได้รับคำขอบคุณจาก: naekkhung

31 ส.ค. 63 , 15:37:57
ตอบกลับ #2

naekkhung

: รวมฟิวส์ Text
« ตอบกลับ #2 เมื่อ: 31 ส.ค. 63 , 15:37:57 »
ขอบคุณครับมากครับ

 

31 ส.ค. 63 , 16:03:16
ตอบกลับ #3

PNR

: รวมฟิวส์ Text
« ตอบกลับ #3 เมื่อ: 31 ส.ค. 63 , 16:03:16 »
เราสามารถที่จะพอทำได้ครับ โดยใช้การกำหนด ประกาศตัวแปรเป็น Public นะครับ
ผมสมมุติ text1 ถึง text3 และ textbox แสดงชื่อ total
เพราะโดยปกติ .Text จะใช้ได้กับ คอนโทรลที่ โฟกัสอยู่เท่านั้น
เราจึงควรสร้างตัวแปรขึ้นมาเก็บค่าไว้ก่อนเพื่อนำไปต่อกับ ตัวแปรต่อๆไป ครับ

ดังตัวอย่างโค้ดนี้

โค๊ด: [Select]
Option Compare Database
Public strText1, strText2, strText3 As Variant

Private Sub Form_Current()
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub

Private Sub Text1_Change()
If Len(Me.Text1.Text) > 0 Then
strText1 = Me.Text1.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text2_Change()
If Len(Me.Text2.Text) > 0 Then
strText2 = Me.Text2.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text3_Change()
If Len(Me.Text3.Text) > 0 Then
strText3 = Me.Text3.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
« แก้ไขครั้งสุดท้าย: 01 ก.ย. 63 , 10:46:00 โดย PNR »
Time to stop for me  :dizzy:
 
โพสต์นี้ได้รับคำขอบคุณจาก: UnKnown, naekkhung

02 ก.ย. 63 , 08:10:50
ตอบกลับ #4

PNR

: รวมฟิวส์ Text
« ตอบกลับ #4 เมื่อ: 02 ก.ย. 63 , 08:10:50 »
แก้ไขเพิ่มเติมโค้ดนิดนึงกรณีลบข้อมูลออกหมด

โค๊ด: [Select]
Option Compare Database
Public strText1, strText2, strText3 As Variant

Private Sub Text1_Change()
If Len(Me.Text1.Text) > 0 Then
strText1 = Me.Text1.Text
Else
strText1 = Null
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text2_Change()
If Len(Me.Text2.Text) > 0 Then
strText2 = Me.Text2.Text
Else
strText2 = Null
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text3_Change()
If Len(Me.Text3.Text) > 0 Then
strText3 = Me.Text3.Text
Else
strText3 = Null
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Time to stop for me  :dizzy:
 

02 ก.ย. 63 , 08:53:40
ตอบกลับ #5

naekkhung

: รวมฟิวส์ Text
« ตอบกลับ #5 เมื่อ: 02 ก.ย. 63 , 08:53:40 »
ขอบคุณมากๆเลยครับ แต่ตอนนี้ถ้าเกิด text1 เราไม่ต้องการกรอกข้อมูล แต่ตอนรวม มันจะมีค่าเว้นวรรคมาด้วย ถ้าเราไม่ต้องการทำยังไงครับ
« แก้ไขครั้งสุดท้าย: 02 ก.ย. 63 , 10:06:41 โดย naekkhung »

 

02 ก.ย. 63 , 12:15:17
ตอบกลับ #6

PNR

: รวมฟิวส์ Text
« ตอบกลับ #6 เมื่อ: 02 ก.ย. 63 , 12:15:17 »
ขอบคุณมากๆเลยครับ แต่ตอนนี้ถ้าเกิด text1 เราไม่ต้องการกรอกข้อมูล แต่ตอนรวม มันจะมีค่าเว้นวรรคมาด้วย ถ้าเราไม่ต้องการทำยังไงครับ
ใช้ Trim เข้ามาช่วยครับ


Option Compare Database
Public strText1, strText2, strText3 As Variant

Private Sub Text1_Change()
If Len(Me.Text1.Text) > 0 Then
strText1 = Me.Text1.Text
Else
strText1 = Null
End If
OutPutString
End Sub

Private Sub Text2_Change()
If Len(Me.Text2.Text) > 0 Then
strText2 = Me.Text2.Text
Else
strText2 = Null
End If
OutPutString
End Sub

Private Sub Text3_Change()
If Len(Me.Text3.Text) > 0 Then
strText3 = Me.Text3.Text
Else
strText3 = Null
End If
OutPutString
End Sub

Private Sub OutPutString()
Me.total = Trim(strText1 & IIf(IsNull(strText2), Null, " " & strText2) & IIf(IsNull(strText3), Null, " " & strText3))
End Sub
« แก้ไขครั้งสุดท้าย: 02 ก.ย. 63 , 12:39:07 โดย PNR »
Time to stop for me  :dizzy:
 
โพสต์นี้ได้รับคำขอบคุณจาก: sjs, naekkhung


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


 

Sitemap 1 2 3 4 5