สมมติให้ Text Box ที่ใส่ Barcode ชื่อ txtBarcode ให้ใช้ Code นี้ครับ
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Or KeyCode = vbKeyTab Then
If IsNull(Me.txtBarcode) Or Me.txtBarcode = "" Then
MsgBox "ยิง Barcode ผิดช่อง", vbCritical, "Error"
Me.txtBarcode.SetFocus
End If
End If
End Sub
ลองดูครับว่าใช้ได้ไหม