DamnTheMachine
Technical User
Hi,
Heres the code I have for scanning into Excel (5 barcodes of each box). What I cant figue out is how to et program to make automatic carriage return after scanning 5th barcode (for the others Im moving using autotab )and loop this util I click Close Form button
Thanks a lot !!
------------------
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'check for a Advice Note number
If Trim(Me.txtAdvice.Value) = "" Then
Me.txtAdvice.SetFocus
MsgBox "Please scan Advice Note number"
Exit Sub
End If
'check for a Part number
If Trim(Me.txtPart.Value) = "" Then
Me.txtPart.SetFocus
MsgBox "Please scan Part Number"
Exit Sub
End If
'check for a Quantity
If Trim(Me.txtQty.Value) = "" Then
Me.txtQty.SetFocus
MsgBox "Please scan Quantity"
Exit Sub
End If
'check for a Supplier Number
If Trim(Me.txtSupplier.Value) = "" Then
Me.txtSupplier.SetFocus
MsgBox "Please scan Supplier Number"
Exit Sub
End If
'check for a Serial number
If Trim(Me.txtSerial.Value) = "" Then
Me.txtSerial.SetFocus
MsgBox "Please scan Serial Number"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtAdvice.Value
ws.Cells(iRow, 2).Value = Me.txtPart.Value
ws.Cells(iRow, 3).Value = Me.txtQty.Value
ws.Cells(iRow, 4).Value = Me.txtSupplier.Value
ws.Cells(iRow, 5).Value = Me.txtSerial.Value
'clear the data
Me.txtAdvice.Value = ""
Me.txtPart.Value = ""
Me.txtQty.Value = ""
Me.txtSupplier.Value = ""
Me.txtSerial.Value = ""
Me.txtAdvice.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Image1_Click()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub
Heres the code I have for scanning into Excel (5 barcodes of each box). What I cant figue out is how to et program to make automatic carriage return after scanning 5th barcode (for the others Im moving using autotab )and loop this util I click Close Form button
Thanks a lot !!
------------------
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'check for a Advice Note number
If Trim(Me.txtAdvice.Value) = "" Then
Me.txtAdvice.SetFocus
MsgBox "Please scan Advice Note number"
Exit Sub
End If
'check for a Part number
If Trim(Me.txtPart.Value) = "" Then
Me.txtPart.SetFocus
MsgBox "Please scan Part Number"
Exit Sub
End If
'check for a Quantity
If Trim(Me.txtQty.Value) = "" Then
Me.txtQty.SetFocus
MsgBox "Please scan Quantity"
Exit Sub
End If
'check for a Supplier Number
If Trim(Me.txtSupplier.Value) = "" Then
Me.txtSupplier.SetFocus
MsgBox "Please scan Supplier Number"
Exit Sub
End If
'check for a Serial number
If Trim(Me.txtSerial.Value) = "" Then
Me.txtSerial.SetFocus
MsgBox "Please scan Serial Number"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtAdvice.Value
ws.Cells(iRow, 2).Value = Me.txtPart.Value
ws.Cells(iRow, 3).Value = Me.txtQty.Value
ws.Cells(iRow, 4).Value = Me.txtSupplier.Value
ws.Cells(iRow, 5).Value = Me.txtSerial.Value
'clear the data
Me.txtAdvice.Value = ""
Me.txtPart.Value = ""
Me.txtQty.Value = ""
Me.txtSupplier.Value = ""
Me.txtSerial.Value = ""
Me.txtAdvice.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Image1_Click()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub