Ricardasr25
New Member
- Joined
- Dec 29, 2013
- Messages
- 21
Hi Guys,
I have a code in userform which I use to transfer data from one sheet to another when the barcode is scanned into the userform textbox(txtOrder), the barcode with order number contains 6 digits .
I have another textbox in userform called txtOperator, this textbox is also filled when scanning the barcode but now it contains only two letters.
So my issue is if not correct textbox is selected by operators it my cause barcode to scan into wrong textbox, lets say that order number will be scanned into operators textbox(txtOperator) and off course it could be in opposite way.
This is what i would like to achieve:
Barcode scanning issue Please help
http://www.excelforum.com/excel-prog...-scanning.html
1.txtOperator textbox - Check if barcode contains 2 letters and if it is true leave it in a txtOperator textbox, but if it's more than 2 scan into txtOrder
2.txtOrder textbox - check if barcode contains more than 2 letters and if it is true leave it in txtOrder textbox, but if it's equals 2 letters scan into txtOperator
Below is my code and i also attached the file.
Thanks in advance for your help.
I have a code in userform which I use to transfer data from one sheet to another when the barcode is scanned into the userform textbox(txtOrder), the barcode with order number contains 6 digits .
I have another textbox in userform called txtOperator, this textbox is also filled when scanning the barcode but now it contains only two letters.
So my issue is if not correct textbox is selected by operators it my cause barcode to scan into wrong textbox, lets say that order number will be scanned into operators textbox(txtOperator) and off course it could be in opposite way.
This is what i would like to achieve:
Barcode scanning issue Please help
http://www.excelforum.com/excel-prog...-scanning.html
1.txtOperator textbox - Check if barcode contains 2 letters and if it is true leave it in a txtOperator textbox, but if it's more than 2 scan into txtOrder
2.txtOrder textbox - check if barcode contains more than 2 letters and if it is true leave it in txtOrder textbox, but if it's equals 2 letters scan into txtOperator
Below is my code and i also attached the file.
Thanks in advance for your help.
Code:
[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">Private Sub txtOrder_Change()
If Len(UserForm1.txtOrder) = 6 Then
UserForm1.TextBox1.Visible = False
UserForm1.TextBox1.Visible = True
'Application.ScreenUpdating = False
Dim strSearch As String
Dim rngFound As Range, firstAddress As String
Dim lngCounter As Long
Dim strAddress As String
Dim lngHelp As Long
Dim arrCol As Variant
Dim Ctrl As Control
Dim A As Long, B As Long
Dim MyName As String, myRange As Range
Dim found As Range
Dim WSdb As Worksheet
Dim C As Long
Dim NextRow As Long
Dim aCol As Long
Dim aRec As Long
Dim ans As String
For C = 1 To 22
Dim x As Integer
For x = 1 To 22
Next x
MyName = UserForm1.txtOrder.Text
Set myRange = ThisWorkbook.Sheets("Update").Range("Update")
Set found = myRange.Find(MyName, LookIn:=xlValues, LookAt:=xlWhole)
If Not found Is Nothing Then
For Each Ctrl In UserForm1.Controls
If Left(Ctrl.Name, 3) = "lbl" Then
Ctrl.Caption = ""
End If
Next
With ThisWorkbook.Sheets("Update")
With .Range("A:A")
strSearch = UserForm1.txtOrder.Text
Set rngFound = .Find(strSearch, LookIn:=xlValues, LookAt:=xlWhole)
If Not rngFound Is Nothing Then
firstAddress = rngFound.Address
Do
If lngCounter >= 22 Then Exit Sub
lngCounter = lngCounter + 1
UserForm1.Controls("lblProd" & lngCounter).Caption = rngFound(, 1)
UserForm1.Controls("lblDesc" & lngCounter).Caption = rngFound.Offset(, 1)
Set rngFound = .FindNext(rngFound)
Loop While Not rngFound Is Nothing And rngFound.Address <> firstAddress
If UserForm1.Controls("lblDesc" & C).Caption <> "" Then
Set WSdb = Worksheets("Data Collection")
With WSdb
'Database next empty row.
NextRow = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
'Write to worksheet.
.Cells(NextRow, 1) = UserForm1.Controls("txtOperator")
.Cells(NextRow, 2) = UserForm1.Controls("txtTime")
.Cells(NextRow, 3) = UserForm1.Controls("lblProd" & C).Caption
.Cells(NextRow, 4) = UserForm1.Controls("lblDesc" & C).Caption
txtTime.Value = Format(Time, "Long Time")
'Reset the next empty row.
NextRow = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
End With
End If
lngCounter = 0
UserForm1.txtOrder.SetFocus
UserForm1.txtOrder.SelStart = 0
UserForm1.txtOrder.SelLength = Len(UserForm1.txtOrder.Text)
End If
End With
End With
End If
Next
End If
End Sub</code>