Add records to a table in batch

razorking

Registered User.
Local time
Today, 05:15
Joined
Aug 27, 2004
Messages
332
Hello,

Not sure if this is best posted in tables or not - so posting it here. I have a database that is used to create serialized stickers for inventory. I am using an auto-number field to give each record a unique serial number for labeling and barcoding. Currently to enter new records - prior to printing the labels - the user has to enter item number information in fields, and has to do this for each new record. So for example - if there are ten new widgets the user has to enter data for the ten new records. I am looking for a way to enter the item information once - then have a field to enter the number of items/records (10 for example) and have the database automatically populate ten new records into the table each with a unique serial number?

Hope that makes sense. Will appreciate any ideas.

Thanks!
 
you'll need a loop in vba, something like

Code:
for I=1 to me.txtNumberRequired
    currentdb.execute("INSERT INTO myTable (ItemNo, WidgetName) VALUES(" & me.txtitemNo & ", '" & me.txtitemName & "')")
next i
 
docmd.runsql "insert into yourTableName (ItemNo, WidgetName) select top " & clng(me.txtNumberOfRecordsToMake) " & Me.txtItemNo & ", '" & Me.txtWidgetName & "' From yourTableName"
 
Thanks for the replies - let me test some of these ideas
 

Users who are viewing this thread

Back
Top Bottom