Multiple items

YouMust

Registered User.
Local time
Yesterday, 16:43
Joined
May 4, 2016
Messages
106
Howdy, I wonder if anyone can point me to an article or what not that can guide me through this.

I want to make a form where I scan a barcode, each component has an individual barcode. which would start from the first one (ie)

10 components are delivered with a starting bar-code of 1001
the last component would have a barcode of 1011.

I want to scan it once and enter a quantity and access will generate the other components barcodes and populate the table?

is this possible>?
 
possible.
my advice is to make index in the barcode field in your table unique without duplicate.
supposed you have two textboxes on your form, txtBarCode (for barcode) and txtQty (for how much sequence to generate).

you can do the update through the form's after update event, or through each control's after update event.

on this example the form is unbound.

on form's event:

private sub form_afterupdate()
dim db as dao.database
dim i as integer
dim count as integer
set db = currentdb
if trim(me.txtBarCode & "") <> "" And trim(Me.txtQqty & "") <> "" Then
count = CInt(me.TxtQty)-1
for i = 0 to count step 1
db.execute "insert into yourTableName ([barcodeField]) select " & _
Val(me.txtBarCode) + i & ";"
next i
end if
set db = nothing
end sub

same process with control's event:

private sub txtBarCode_afterupdate()
if trim(me.txtBarCode & "") <> "" And trim(Me.txtQqty & "") <> "" Then _
InsertNewBarCode
end sub

private sub txtQty_afterupdate()
if trim(me.txtBarCode & "") <> "" And trim(Me.txtQqty & "") <> "" Then _
InsertNewBarCode
end sub

private sub InsertNewBarCode()
dim db as dao.database
dim i as integer
dim count as integer
set db = currentdb
count = CInt(me.TxtQty)-1
for i = 0 to count step 1
db.execute "insert into yourTableName ([barcodeField]) select " & _
Val(me.txtBarCode) + i & ";"
next i
set db = nothing
end sub
 
Are all the bar codes 1001 - 1011? That doesn't make sense. Or are they all 1001x - 1011x where x represents more digits. Also if there are alway ten and the bar codes of nine can be determine by one then does it make sense to store all ten?

I assume the bar code reader would just act like keyboard input. Is this true?

To answer you question I pretty sure this is possible and we can tell you how if you give us more specific information.
 
sorry I meant to say that the barcodes will increment
so if i scan or enter one barcode which as an example is 001 and i enter a quantity of say 5, then access will populate the table with 5 barcodes incrementing by 1 starting at 001 and ending in 005.

there is 4 bits of information that need to be logged

starting barcode
Date received
Quantity
Part Number

later more info will be added to the table as the product goes through the production process.

thanks arnelgp I'll give that a try and thanks sneuberg :)


Code:
Private Sub newpart_Click()
Dim db As dao.Database
Dim i As Integer
Dim count As Integer
Set db = CurrentDb
If Trim(Me.txtBarCode & "") <> "" And Trim(Me.TxtQty & "") <> "" Then
count = CInt(Me.TxtQty) - 1
For i = 0 To count Step 1
db.Execute " tblgoodsin ([barcodeField]) select " & _
Val(Me.txtBarCode) + i & ";"
Next i
End If
Set db = Nothing
End Sub

I get 'error engine cannot find the input table or query ' tblgoodsin ([barcodeField]) select 1;'

the table "tblgoodsin" is there
 
Last edited:
I'm not sure what im doing wrong, I've made a form the the table.
Inputting values manually without the script works fine all be it one at a time.

but as soon as I put that script in I get

Run-time error '3087'
The mircrosoft database engine cannot find the input table or the query ' tblgdin ([barcodefiled]) select 100 (100 being the quantity). make sure it exists and that it's name is spelled correctly .

msac.jpg


Kind Regards
YouMust
 
thought I'd update this thread
It was my mistake i deleted "insert into" on this line:
Code:
db.execute "insert into yourTableName ([barcodeField]) select " & _
Val(me.txtBarCode) + i & ";"

This is working now! thank you
I've just finished college so i can spend more time on this now.
next is to add date and part number to each barcode generated.
I've got myself some VBA and access books so its time to start reading!
 

Attachments

Users who are viewing this thread

Back
Top Bottom