Print from barcode scan

AlexZouev

New member
Local time
Yesterday, 21:48
Joined
Dec 24, 2018
Messages
1
Hi Everyone,
I have a shop and at the reception of goods I have to print a label for each individual product. I have a table that contains Barcode Number, name and # of items in each Carton.

I want to create a report based on a criteria query, whereby I will scan a barcode and a task from Access is to print out the exact number of labels for each product based on the amount of items in each carton.

Can it be done?

Brgds, Alex
 
create another table (tblNumbers) with fields:
Code:
id (autonumber)
num (integer)
fill the field (num) from 1 upto the 10000 (or maximum you want).
or you can write a code in a module to insert record:
Code:
private sub test()
dim i as integer
for i=1 to 10000
   currentdb.execute "insert into tblNumbers(num) values (" & i & ");"
next
end sub

now, take your barcode table create a query.
add tblNumbers on the query.

add [barcode number] fields on the query.
add the [num] field from the new table.

add Criteria on [num] field.
Criteria: <= [number of items in carton field]

save the query and use in your report.
 
Another way:
Code:
Private Sub cmdTest01_Click()
Dim sSQL As String
Dim iCopies As Integer
Dim rst As DAO.Recordset

'Selecting goods marked to print
    sSQL = "SELECT * FROM tblGoods WHERE PrintNow=True"
    Set rst = CurrentDb.OpenRecordset( sSQL, dbOpenDynaset)
    
    With rst
        Do Until .EOF = True 'Loop to end of recordset
            
            sSQL = "Good_ID= " & !Good_ID 'Where condition for report (One good by ID)
            iCopies = !Items ' ... based on the amount of items in each carton.
            If iCopies > 0 Then
                DoCmd.OpenReport "Good_Label", acViewNormal, , sSQL, acHidden
                DoCmd.PrintOut acPrintAll, , , , iCopies 'Printing ...
                DoCmd.Close acReport, "Good_Label"
            End If
            .Edit
                !PrintNow = False
            .Update
            .MoveNext
        Loop
    End With
    
    
On Error Resume Next
    rst.Close
    Set rst = Nothing
End Sub
 
Last edited:
yes the code will work if the user doesn't want to view it first.
 

Users who are viewing this thread

Back
Top Bottom