Create Records automatically

R

Richie

Hi, I have a database that records serial numbers. I need a form that will
create a new record for each serial number but instead of having a different
form for each serial number, as this is too time consuming, I need to put in
the first SN say 1 and then enter a quantity say 10 and it will then create
10 Records from 1-10 in the SN table. Any ideas please!

Richie
 
R

ryguy7272

Would you need a Form or a Report? I can think of a way to do it in a
Report. Create a query to group your data in your Tables into your
predefined groups, then build a report based on that result. Finally, look
here for a sample of how to create dynamic reports:
http://www.fontstuff.com/access/acctut19.htm

Then look here for a good tutorial on 'sorting and grouping' Reports:
http://www.datapigtechnologies.com/flashfiles/groupinginaccessrpts.html

If you want to pass a value from a Form to a Report, take a look at this:
http://www.datapigtechnologies.com/flashfiles/passparamtoreport.html

I've used all of these techniques before, and all work extremely well, but
it DOES take a little work to set up and get everything straightened out
initially.

Good luck,
Ryan---
 
K

KC-Mass

Set up a form frmSerialAdd with two text boxes txtStartrNum
for the number you want to start with and txtHowMany
for how many you want to create. Then launch something like
the below code to create them and stick the in a table
tblSerialNumbers.

Regards

Kevin

Sub BuildSerialNumbers()
Dim lngTimesThrough As Long
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSerialNumbers")
lngTimesThrough = 0
Do While lngTimesThrough <= Forms!frmSerialAdd!txtHowMany - 1
rs.AddNew
rs!SerialNumber = Forms!frmSerialAdd!txtStartNum + lngTimesThrough
rs.Update
lngTimesThrough = lngTimesThrough + 1
Loop
Set rs = Nothing
Set db = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top