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

เริ่มโดย ekppom, 03 พ.ค. 19 , 12:28:17

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

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

รูปครับ
  •  

ปิ่นณรงค์

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

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
:love: :grin:
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: ekppom

ekppom

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