[SOLVED] Increment by 1
hello,
I hope you can help I've made a script that takes:
User inputs the first barcode '100' part number and date received followed by the quantity (10).
the VBA should now make 10 entries in the table and increase the barcode on each record by one.
so we will have 10 barcodes starting at 100 and finishing at 109 (total 10 barcodes).
But my code is just adding another digit on to the end of the barcode and counting up from there, so the barcode reads 1001 instead of 101.
some advise would be fantastic!
Kind Regards
Edit fixed just changed the & to +
hello,
I hope you can help I've made a script that takes:
- Barcode
- Part Number
- Recieved date
- quantity
User inputs the first barcode '100' part number and date received followed by the quantity (10).
the VBA should now make 10 entries in the table and increase the barcode on each record by one.
so we will have 10 barcodes starting at 100 and finishing at 109 (total 10 barcodes).
But my code is just adding another digit on to the end of the barcode and counting up from there, so the barcode reads 1001 instead of 101.
Code:
Private Sub ok_Click()
On Error GoTo ErrorHandler
Dim i, count As Long
If (IsNull(Me.txtBarCode) Or Trim(Me.txtBarCode & "") <> "") Or (IsNull(Me.QtyTxt) Or Trim(Me.QtyTxt & "") <> "") Or IsNull(Me.Recieved_date) Then
DoCmd.Hourglass True
count = CLng(Me.QtyTxt) - 1
For i = 0 To count
DoCmd.RunSQL "INSERT INTO tblGoodsIn (Barcode, PrtNo, [Recieved date]) VALUES(" & CLng(Me.txtBarCode & i) & ", '" & Me.PrtNo & "', #" & Me.Recieved_date & "#);"
Next i
DoCmd.Hourglass False
MsgBox "Successfully Added", vbInformation, "Completed"
Else
MsgBox "Barcode, Recieved Date and Quantity is required.", vbExclamation, "Warning!"
Exit Sub
End If
Exit_Handler:
DoCmd.Hourglass False
Exit Sub
ErrorHandler:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure DeleteFailure", vbCritical, "ERROR"
Resume Exit_Handler
End Sub
some advise would be fantastic!
Kind Regards
Edit fixed just changed the & to +
Code:
VALUES(" & CLng(Me.txtBarCode + i)
Last edited: