>We have a labor system that we will sometimes use with a barcode reader. Currently the employee keys in their employee number and a messagebox confirmation pops up and confirms that they are who they say they are. have added a "~" character into the barcode of the employee's number on their badge so instead of "1234" it is acually "~1234" and I was thinking that I could change the Keypress or another method on the textbox on the labor entry form so it absorbs the "~" when it sees it and reads the 4 characters after that and displays them in the textbox without the "~" and sets a flag that the user is using a barcode. What is the best way to absorb a key, with which method?
Dug,
great minds think alike. That is exactly the way we have employees barcode into our time clock software. I suggest an easy way. Create a new text box called txtBarcode. This will capture any incomming barcodes. Then...
Set the form keypreview = .T.
Use this code in the form Keypress Method to capture the incomming ~ and set focus to the barcode text box that will capture the rest of the incomming code. You can then do whatever you want with the entry in txtBarcode. If the user just starts typeing it the input would go into the normal id text box. After captureing the barcode be sure to set the txtBarcode properties back to .f. They should start that way also so no text accidentally gets in.
case nKeyCode = 126
With Thisform
.barcode = .t.
.CurrentPlace = .ActiveControl
.txtbarcode.Value = ''
.txtbarcode.Visible = .t.
.txtbarcode.Enabled = .t.
.txtbarcode.SetFocus()
EndWith
NoDefault
Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn