Insert the same value multiple times in a query

I want to insert the same value multiple times into my database using the same:

ModelNumber
SoldTo
ShipTo
DateCode

and then a unique serial number 1 - 999 per unit within that update. The record ID is an autonumber. Any suggestions?
timberline503Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
use vba codes

sub InsertRecords()
dim nRec as long, j as long, rs as dao.recordset
nrec=999
set rs=currentdb.openrecordset("tableA")
for j=1 to 999
       with rs
           .addnew
            !ModelNumber=<some value>
            !SoldTo=<some value>
            !ShipTo =Date()
            !DateCode=<some code>
           .update
       end with
next

end sub




.
0
timberline503Author Commented:
Get this error message. Can we do this in SQL?
0
Dale FyeCommented:
I have a table (tbl_Numbers) in all of my databases.  It contains a single field (lngNumber) and ten records (the values 0 to 9).  With that table, I can write a query to generate any number of successive numbers, in your case:

SELECT Hundreds.lngNumber * 100 + Tens.lngNumber * 10 + Ones.lngNumber as [lngNumber]
FROM tbl_Numbers as Hundreds, tbl_Numbers as Tens, tbl_Numbers as Ones

This query will create generate numbers from 0 to 999

You could then write a query something like:

INSERT INTO yourTable (Field1, Field2, Field3, lngNumber)
SELECT "Text for Field1", "Text for Field2", NumberForField3, lngNumber
FROM qry_Numbers
WHERE qry_Numbers.lngNumber >0
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Rey Obrero (Capricorn1)Commented:
what error message?


.
0
timberline503Author Commented:
I posted a photo of the error message. I will post again
ErrorForSerialNumber.jpg
0
Rey Obrero (Capricorn1)Commented:
take note of what i posted


set rs=currentdb.openrecordset("tableA")

use this in your code

set rs=currentdb.openrecordset("tblSerialNumbers")
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.