lpking2005
Board Regular
- Joined
- Mar 21, 2011
- Messages
- 140
Hi,
I have a system where the user scans a barcode into a textbox and it returns data from another workbook.
The problem is that the barcode will either be 8 or 13 digits in length.
If i put the code in Textbox_change event, the code will trigger for each number and therefore will always try to run my macro when it gets to 8 digits even if its a 13 digit barcode.
The Text_Afterupdate seems like the better approach but it needs the user to interact with a key for the macro to run.
I need to run as soon as the user scans the barcode because they have to scan a different barcode after the first one.
This is the code im using so far...
Any help would be appreciated.
Thanks.
I have a system where the user scans a barcode into a textbox and it returns data from another workbook.
The problem is that the barcode will either be 8 or 13 digits in length.
If i put the code in Textbox_change event, the code will trigger for each number and therefore will always try to run my macro when it gets to 8 digits even if its a 13 digit barcode.
The Text_Afterupdate seems like the better approach but it needs the user to interact with a key for the macro to run.
I need to run as soon as the user scans the barcode because they have to scan a different barcode after the first one.
This is the code im using so far...
Any help would be appreciated.
Thanks.
Code:
Private Const BARCODE_LENGTH As Integer = 13
Private Const MF_BARCODE_LENGTH As Integer = 8
_____________________________________________________________________________________
Private Sub TextBox1_AfterUpdate()
'Code runs after full number is entered and user clicks/tabs to EAN field
If Len(TextBox1.Text) = BARCODE_LENGTH Or Len(TextBox1.Text) = MF_BARCODE_LENGTH Then
disableClose = True
Call CheckEANData
Else
Exit Sub
End If
End Sub