1
ห้อง MS Access / : การกำหนดการตรวจสอบค่าที่กรอกใน form
« เมื่อ: 26 ก.พ. 63 , 13:41:49 »อ้างถึง
บ้านเลขที่ ให้เป็นตัวเลขและ มี / ได้Private Sub txtAddress_KeyPress(KeyAscii As Integer)
If (KeyAscii > 46 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else:
KeyAscii = 0
End If
End Sub
อ้างถึง
3. เบอร์ = ตัวเลข ใน tbl เป็น text
สมมุติ txtPhoneNumber
Private Sub txtPhoneNumber_KeyPress(KeyAscii As Integer)
If (KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 8) Then
KeyAscii = KeyAscii
Else:
KeyAscii = 0
End If
End Sub
จะพิมพ์ได้เฉพาะตัวเลขครับ แต่สามารถใช้ Space Bar ได้ เผื่อว่าต้องการพิมพ์เบอร์ 000 0000000 แบบนี้
อ้างถึง
NameEN = เฉพาะอักษรภาษาอังกฤษ
Private Sub txtWordsEng_KeyPress(KeyAscii As Integer)
If (KeyAscii > 65 And KeyAscii < 90) Or (KeyAscii > 97 And KeyAscii < 122) Then
KeyAscii = KeyAscii
Else:
KeyAscii = 0
End If
End Sub
อ้างถึง
ชื่อไทย = เฉพาะอักษรไทยPrivate Sub txtWordsTH_KeyPress(KeyAscii As Integer)
If Not (KeyAscii > 0 And KeyAscii < 32) And Not (KeyAscii > 32 And KeyAscii < 127) Then
KeyAscii = KeyAscii
Else:
KeyAscii = 0
End If
End Sub
สำหรับ ใส่ชื่อไทย กำหนดให้ยอมรับการกด Spacebar ได้เพื่อให้เว้นช่องว่างกรณี มีทั้งชื่อและนามสกุล
โพสต์นี้ได้รับคำขอบคุณจาก: NattakornC