Textbox Help

Acropolis

Registered User.
Local time
Today, 04:04
Joined
Feb 18, 2013
Messages
182
I have a textbox on a form, in which I enter a serial number of a product to open the relating form.


All works well when typed in a button pressed.


What I want to be able to do is scan the barcode on the product, this will then enter the serial number in the textbox and open the form.


The barcode scanner returns an "enter" on the end of the barcode it scans.


I have used a Onkeydown event, looking for keycode 13.


The problem is when it detects the keycode 13, the value of the textbox is showing as null so the right bit of code does kick in, until I scan another barcode, then it returns the value of the first one scanned, and the third the second etc.


Is there a way to resolve this easily, am I missing something really simple in how to update the value of the text box before running the code.


Thanks


Code:
If KeyCode = 13 Then
    Debug.Print Me.txtSerial
    'Do something
End If
 
Try
Debug.Print Me.txtSerial.Text
 
You could use After Update event to replace the Chr(13) to nothing. Something like.
Code:
Private Sub txtSerial_AfterUpdate()
    Me.txtSerial = Replace(Me.txtSerial, Chr(13), "")
End Sub
 

Users who are viewing this thread

Back
Top Bottom