เคลียร์ข้อมูล Textbox
กระทู้เก่าบอร์ด อ.Yeadram

 1,502   6
URL.หัวข้อ / URL
เคลียร์ข้อมูล Textbox

ใน Form ผมมี Textbox หลายกล่อง อยากเขียน code หรือ ทำเป็นฟังก์ชั่น แล้วเรียกใช้งาน ทำให้น่าดูกว่านี้   ขอความกรุณาช่วยแนะนำด้วยครับ ขอบคุณครับ
     
     Me.Text29.SetFocus
     Text29.Text = ""
     Me.Text31.SetFocus
     Text31.Text = ""
     Me.Text33.SetFocus
     Text33.Text = ""
     Me.Text35.SetFocus
     Text35.Text = ""
     Me.Text37.SetFocus
     Text37.Text = ""
     Me.Text39.SetFocus
     Text39.Text = ""
     Me.Text41.SetFocus
     Text41.Text = ""
     Me.Text43.SetFocus
     Text43.Text = ""
     Me.Text45.SetFocus
     Text45.Text = ""

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

1 @R14101
me.Text29 = ""
2 @R14108
ขอบคุณมากครับ
3 @R14109
Dim i As Integer
For i = 29 To 45
    Me("Text" & i) = ""
Next
4 @R14110
อีก 1 ทางเลือก ที่ไม่ต้องระบุอะไร มากมาย
เขียน procedure ไว้ใช้งาน
Public Sub ClearTextBoxes(frmClearMe As Form)

Dim txt As Control

'clear the text boxes
For Each txt In frmClearMe

If TypeOf txt Is TextBox Then txt.Value = ""

Next

End Sub

จากฟอร์มที่ต้องการ เคลียร์ textbox
ClearTextBoxes Me
5 @R14115
Dim i As Integer
For i = 29 To 45
   Me("Text" & i) = ""
   i = i + 1
Next

เพิ่ม i = i + 1
ใช้ได้เลยครับ   ขอบคุณอีกครั้งนะครับ
6 @R14148
เปลี่ยนเป็นแบบนี้ดีกว่าครับ

For i = 29 To 45 Step 2
   Me("Text" & i) = ""
Next
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.2955s