ต้องการให้Enterแล้วไม่มีผลอะไรเกิดขึ้นครับ


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

03 พ.ค. 62 , 12:28:17
อ่าน 897 ครั้ง

ekppom

สวัสดีครับ ผมมีปัญหาหากเคอร์เซอร์อยู่ในช่องบาร์โค้ดแล้วบังเอิญไปEnterทั้งๆที่ยังไม่ใส่ตัวเลข เคอร์เซอร์จะกระโดดไปที่Subform ในช่องจำนวนตามรูปครับ ผมต้องการให้ ถ้าไม่มีข้อมูลใดใดในช่องบาร์โค้ดหากมีการกดปุ่มEnter จะไม่มีผลใดใดเกิดขึ้นเลย ขอคำแนะนำเรื่องโค้ดครับ
ตัวอย่างโค้ดช่องบาร์โค้ด
Private Sub Barcode_BeforeUpdate(Cancel As Integer)
If Nz(Forms!Sale!Barcode, "") = "" Then Exit Sub
If DCount("*", "Product", "[Item-no]=Forms!Sale!Barcode") > 0 Then
Else
MsgBox "ไม่พบข้อมูลสินค้า", vbExclamation, "พบข้อผิดพลาด"
Cancel = True
End If
End Sub

โค้ดปุ่มหลังจากที่ใส่ข้อมูลในช่องบาร์โค้ดแล้วกดEnter
Private Sub Command122_Enter()
On Error Resume Next
Forms("Sale").subformsale.Form.Item_no = Barcode
subformsale.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "Barcode"
Barcode.SetFocus
Barcode = Null
End Sub

รูปครับ

 

03 พ.ค. 62 , 12:58:33
ตอบกลับ #1

ปิ่นณรงค์

แก้เป็นแบบนี้ได้ไหม เป็นการกำหนดเงื่อนไขว่า ถ้า textbox barcode ว่าง ก็ให้ออกจากการทำงานที่เหลือ

โค๊ด: [Select]
Private Sub Command122_Enter()
On Error Resume Next
if isnull(me.Barcode) then
Me.Barcode.SetFocus
exit sub
else
Forms("Sale").subformsale.Form.Item_no = Barcode
subformsale.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "Barcode"
Barcode.SetFocus
Barcode = Null
end if
End Sub
« แก้ไขครั้งสุดท้าย: 03 พ.ค. 62 , 13:09:37 โดย ปิ่นณรงค์ »
:love: :grin:
 
โพสต์นี้ได้รับคำขอบคุณจาก: ekppom

03 พ.ค. 62 , 13:47:39
ตอบกลับ #2

ekppom

ทำได้แล้วครับ ขอบคุณมากๆเลยนะครับ

 


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


 

Sitemap 1 2 3 4 5