Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No keyboard entry only barcode scanned

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
Is there a way to keep a user from typing something into an unbound txtbox with the keyboard but allowing them to scan a barcode label to populate the txt box? After the scan I populate other txtboxes based on the barcode scanned to prevent typing errors.
 
If your textbox was called 'txtBarcode'

Set it's property to 'Locked', in code, this would be:

txtBarcode.Locked = True

Then you want some code like this:

Private Sub cmdScan_Click()

getScannedBarcode(Variables to pass to function)

txtBarcode.Locked = False
txtBarcode.Value = strBarcode
txtBarcode.Locked = True

End Sub

Hope that helps.
 
i would try something like this
Private Sub Text0_KeyPress(KeyAscii As Integer)
If Not KeyAscii = 8 Then
KeyAscii = (27)
End If
End Sub
so any key press execpt for backspace is canceled
note you can still past in the text box
 
Hey pwise and th0r0n thanks for the quick respones.

pwise I gave yours a try but I still couldn't scan into the text box. Maybe because the scanner is in series with the keyboard? I dunno. Maybe the scan is seen as keystrokes.

th0r0n I'm not quite following you. If the txtbox is locked say on form load, wouldn't that require another txtbox or a seperate form with a single txtbox on it to pass as the variable?
 
jadams0173:
i did try this code but i just copied from one of my programs i dont have a scanner @ this place i am today
try playing with this like
testing for the len of the keypress len of the keypress
check to see if by a scan there is a key down

please let me know what worked
 
Thanks for the ideas pwise. I'll give it a try and let you know how I come out.
 
When the scan is made the keypress and keydown events fire. I've played around with trying to check the Len to no avail...Any other suggestions?
 
try looking @ me.control.value or me.control.text if ther is any way that you can identify that it has more then 1 charcther it is a scan otherwise cancel with KeyAscii = (27)
or KeyAscii = (0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top