Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you add blank records

Status
Not open for further replies.

vince99

IS-IT--Management
Mar 1, 2001
63
US
I have created a table and I want to add 10,000 blank records to it. I want my users to start entering data at the 10,001 record. I need the first 10,000 records to be blank so that I can insert other data into them when I have time.

Is there an easy way of doing this?

Thanks for the help...
 
All you need to do is append a record to your table with the value of 10000 to the autonumber field. From then on the autonumber will begin at 10001.
 
yes, but how can I have it so that the 10,000 records before 10,001 are blank records?

Thanks again
 
Hi,

Normally (all the time?) it is unneccessary to store a blank record in a database, after all, it sort of alleviates the need for the database in the first place.

It looks to me that your concern is that the data will be out of some predefined order. If so, don't worry, data management (reading, sorting and manipulating) is what databases do best. If you kick off a table with the first record ID at 10,001, you will be able to see the first 10000 you want to add later (at the beginning), by using the table ID as an index (the original records would need to be numbered from 1 to 10000 of course). You could also sort/index by date fields etc as required.

If it is imperitive that you have your 10,000 blank records, you will need to create a function which has a loop which inserts a record with an auto-generated counter, and loops 10,000 times. Whilst it is minimal programming, trust me, it isn't worth the effort, and only means more work for you, the database and no benefit to anyone.

cheers & happy days
 
Thanks for the reply.....

I am new to access and dont know anything about programming.

Would you be kind enough to give me an example?

Thanks
 
create a form with one command button on it. Open the Properties window, if not already open.
Click on the Events Tab and then Select Event Procedure from the dropdown box associated with the Click Event (click once in the box next to the word Click and the dropdown box should appear). Once you've selected Event Procedure, click on the 3 dots next to the dropdown box, and you should appear in the Form's Code window, place the cursor below the line for Private Sub Command1_Click() and above the Line for End Sub as shown below

Private Sub Command0_Click()
' cursor should be here
End Sub

Then add the following code depending on which version of Access you have
(Be sure to change the name of the Table from TableNameGoesHere to the actual name of your table)

For Access 97

Dim db As DAO.database, rst As DAO.Recordset
Dim intI As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("TableNameGoesHere")
With rst
For intI = 1 To 10000
rst.AddNew
rst.Update
Next intI
End With
MsgBox "Done"

For Access 2000
Dim rst As New ADODB.Recordset
Dim intI As Integer
rst.Open "TableNameGoesHere", CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
With rst
For intI = 1 To 10000
rst.AddNew
rst.Update
Next intI
End With
MsgBox "Done"

Then close the Code window, open the form and click on the command button.

HTH

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top